Skip to main content

Class: CheckRegistrationTokenService

api-login/auth/check-registration-token.service.CheckRegistrationTokenService

Service to validate a registration token and retrieve the referenced nodes

Constructors

constructor

new CheckRegistrationTokenService(tokenService, activeLoginService)

Parameters

NameType
tokenServiceTokenService
activeLoginServiceActiveLoginService

Defined in

gropius-login-service/backend/src/api-login/auth/check-registration-token.service.ts:14

Properties

activeLoginService

Private Readonly activeLoginService: ActiveLoginService

Defined in

gropius-login-service/backend/src/api-login/auth/check-registration-token.service.ts:16


logger

Private Readonly logger: Logger

Defined in

gropius-login-service/backend/src/api-login/auth/check-registration-token.service.ts:13


tokenService

Private Readonly tokenService: TokenService

Defined in

gropius-login-service/backend/src/api-login/auth/check-registration-token.service.ts:15

Methods

checkActiveLoginValid

Private checkActiveLoginValid(activeLogin, loginData, activeLoginId): void

Checks wether both active login and login data are given and valid.

Valid means not set invalid and not expired. For the loginData it is checked, that it is still in the LoginState.WAITING_FOR_REGISTER

Parameters

NameTypeDescription
activeLoginActiveLoginThe activeLog innstance to check. Optional
loginDataUserLoginDataThe loginData instance to check. Optional
activeLoginIdstringThe id of the activeLogin instance. Just used for error messages. Required

Returns

void

Throws

UnauthorizedException If either activeLogin or loginData are not given or invalid in any way.

Defined in

gropius-login-service/backend/src/api-login/auth/check-registration-token.service.ts:30


getActiveLoginAndLoginDataForToken

getActiveLoginAndLoginDataForToken(token, userMustBe?): Promise<{ activeLogin: ActiveLogin ; loginData: UserLoginData }>

Validates a registration token and returns the loginData as well as activeLogin that created it.

Additionally checks that the user linked to the loginData is the same as a given user. This can be used to check that new registrations are only linked with oneself and not other user accounts

Parameters

NameTypeDescription
tokenstringThe token string to be validated
userMustBe?LoginUser-

Returns

Promise<{ activeLogin: ActiveLogin ; loginData: UserLoginData }>

The loginData and activeLogin objects that created the given registration token

Throws

UnauthorizedException If no token is given, the token is invalid, the referenced activeLogin or loginData don't exist or are invalid or the user does not match

Defined in

gropius-login-service/backend/src/api-login/auth/check-registration-token.service.ts:105


verifyUserMatches

verifyUserMatches(loginData, userMustBe?): Promise<void>

Verifies that the loginData is for the exact user specified.

Cases:

  • If the loginData has no user, the check passes.
  • If user is not given/undefined, the login data must be unassigned and have no user.
  • If a user is given, the user of the loginData must be the same as the one given.

Parameters

NameTypeDescription
loginDataUserLoginDataThe loginData for which to verify the user
userMustBe?LoginUserThe user to verify or undefined

Returns

Promise<void>

Throws

UnauthorizedException If the user did not match as specified above.

Defined in

gropius-login-service/backend/src/api-login/auth/check-registration-token.service.ts:70