Skip to main content

Class: CheckRegistrationTokenService

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

Service to validate a registration token and retrieve the referenced nodes

Constructors​

constructor​

• new CheckRegistrationTokenService(tokenService, loginDataService, activeLoginService)

Parameters​

NameType
tokenServiceTokenService
loginDataServiceUserLoginDataService
activeLoginServiceActiveLoginService

Defined in​

login-service/src/api-login/check-registration-token.service.ts:19

Properties​

activeLoginService​

• Private Readonly activeLoginService: ActiveLoginService

Defined in​

login-service/src/api-login/check-registration-token.service.ts:22


logger​

• Private Readonly logger: Logger

Defined in​

login-service/src/api-login/check-registration-token.service.ts:18


loginDataService​

• Private Readonly loginDataService: UserLoginDataService

Defined in​

login-service/src/api-login/check-registration-token.service.ts:21


tokenService​

• Private Readonly tokenService: TokenService

Defined in​

login-service/src/api-login/check-registration-token.service.ts:20

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​

login-service/src/api-login/check-registration-token.service.ts:36


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​

login-service/src/api-login/check-registration-token.service.ts:111


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​

login-service/src/api-login/check-registration-token.service.ts:76