UserService
Provides layer to manipulate users.
constructor
Parameters
__namedParametersUserServicePropsRequiredProperties
__container__anyRequiredfeatureFlagRouter_FlagRouterRequiredmanager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredDefault: "user.created"
Events.DELETEDstringRequiredDefault: "user.deleted"
Events.PASSWORD_RESETstringRequiredDefault: "user.password_reset"
Events.UPDATEDstringRequiredDefault: "user.updated"
__configModule__Record<string, unknown>__moduleDeclaration__Record<string, unknown>Accessors
activeManager_
Returns
EntityManagerEntityManagerRequiredMethods
atomicPhase_
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
Type Parameters
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
PromisePromise<TResult>Requiredcreate
Creates a user with username being validated. Fails if email is not a valid format.
Parameters
userCreateUserInputRequiredpasswordstringRequiredReturns
delete
Deletes a user from a given user id.
Parameters
userIdstringRequiredReturns
PromisePromise<void>RequiredgenerateResetPasswordToken
Generate a JSON Web token, that will be sent to a user, that wishes to reset password. The token will be signed with the users current password hash as a secret a long side a payload with userId and the expiry time for the token, which is always 15 minutes.
Parameters
userIdstringRequiredReturns
PromisePromise<string>RequiredhashPassword_
Hashes a password
Parameters
passwordstringRequiredReturns
PromisePromise<string>Requiredlist
Parameters
selectorFilterableUserPropsRequiredconfigobjectRequiredDefault: {}
Returns
retrieve
Gets a user by id. Throws in case of DB Error and if user was not found.
Parameters
userIdstringRequiredDefault: {}
Returns
retrieveByApiToken
Gets a user by api token. Throws in case of DB Error and if user was not found.
Parameters
apiTokenstringRequiredrelationsstring[]RequiredDefault: []
Returns
retrieveByEmail
Gets a user by email. Throws in case of DB Error and if user was not found.
Parameters
emailstringRequiredDefault: {}
Returns
setPassword_
Sets a password for a user Fails if no user exists with userId and if the hashing of the new password does not work.
Parameters
userIdstringRequiredpasswordstringRequiredReturns
shouldRetryTransaction_
Parameters
errRecord<string, unknown> | objectRequiredReturns
booleanbooleanRequiredupdate
Updates a user.
Parameters
userIdstringRequiredupdateUpdateUserInputRequiredReturns
withTransaction
Parameters
transactionManagerEntityManagerReturns
thisthisRequired