AuthService

Source: AuthService.js:73

Service for authentication operations. Handles user login, registration, and authentication logic.


Constructor

new AuthService(): AuthService

Instance Methods

generateAccessToken(UserId: UUID, options?: Object): string

Generates an access token

Parameters

  • UserId (UUID)
  • options (Object, optional, default: "{}")
    • options.expiresIn (string | undefined | null, optional, default: null)

Returns

  • string

authenticateUser(failIfNotLoggedIn?: boolean): function

Middleware generator for user authentication

Parameters

  • failIfNotLoggedIn (boolean, optional, default: true)

Returns

  • function — middleware function

resolveSsoToken(token: string, locale?: string): Promise.<User>

Resolves Single Sign-On Tokens to a user it belongs to

Parameters

  • token (string)
  • locale (string, optional, default: "\"en\"")

Returns

Throws

  • Error — Token has to be a valid and not-expired JWT token
  • Error — User the token belongs to has to (still) exist

generateSsoToken(email: string, locale?: string): Promise

Generate a Single Sign-On token for login via login-link

Parameters

  • email (string) — Username or email address of a user
  • locale (string, optional, default: "\"en\"")

Returns

  • Promise

Throws

  • Error — User with give email/username has to (still) exist
  • Error — User with given username has to have an email address

authenticateAdmin(): function

Middleware generator for admin authentication

Returns

  • function

resolveAdmin( req: _express.Request, res: _express.Response, next: _express.NextFunction, ): Promise

Middleware for resolving admin auth tokens to the Admin

Parameters

  • req (_express.Request)
  • res (_express.Response)
  • next (_express.NextFunction)

Returns

  • Promise