UserService
Provides layer to manipulate users.
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>manager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredEvents.DELETEDstringRequiredEvents.PASSWORD_RESETstringRequiredEvents.UPDATEDstringRequiredAccessors
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.
Parameters
work(transactionManager: EntityManager) => Promise<TResult>Requiredthe transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Potential error handler
Returns
PromisePromise<TResult>Requiredthe result of the transactional work
create
Creates a user with username being validated. Fails if email is not a valid format.
Parameters
the user to create
passwordstringRequireduser's password to hash
Returns
the result of create
delete
Deletes a user from a given user id.
Parameters
userIdstringRequiredthe id of the user to delete. Must be castable as an ObjectId
Returns
PromisePromise<void>Requiredthe result of the delete operation.
generateResetPasswordToken
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
userIdstringRequiredthe id of the user to reset password for
Returns
PromisePromise<string>Requiredthe generated JSON web token
hashPassword_
Hashes a password
Parameters
passwordstringRequiredthe value to hash
Returns
PromisePromise<string>Requiredhashed password
list
Parameters
the query object for find
configobjectthe configuration object for the query
Returns
the result of the find operation
retrieve
Gets a user by id. Throws in case of DB Error and if user was not found.
Parameters
userIdstringRequiredthe id of the user to get.
configFindConfig<User>query configs