UserService
Provides layer to manipulate users.
constructor
Parameters
__namedParameters
UserServicePropsRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredEvents
objectRequiredEvents.PASSWORD_RESET
stringRequiredDefault: "user.password_reset"
Events.CREATED
stringRequiredDefault: "user.created"
Events.UPDATED
stringRequiredDefault: "user.updated"
Events.DELETED
stringRequiredDefault: "user.deleted"
featureFlagRouter_
FlagRouterRequired__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>Requiredlist
Parameters
Default: {}
Returns
listAndCount
Parameters
Default: {}
Returns
retrieve
Gets a user by id. Throws in case of DB Error and if user was not found.
Parameters
userId
stringRequiredDefault: {}
Returns
retrieveByApiToken
Gets a user by api token. Throws in case of DB Error and if user was not found.
Parameters
apiToken
stringRequiredrelations
string[]RequiredDefault: []
Returns
retrieveByEmail
Gets a user by email. Throws in case of DB Error and if user was not found.
Parameters
email
stringRequiredDefault: {}
Returns
hashPassword_
Hashes a password
Parameters
password
stringRequiredReturns
Promise
Promise<string>Requiredcreate
Creates a user with username being validated. Fails if email is not a valid format.
Parameters
user
CreateUserInputRequiredpassword
stringRequiredReturns
update
Updates a user.
Parameters
userId
stringRequiredupdate
UpdateUserInputRequiredReturns
delete
Deletes a user from a given user id.
Parameters
userId
stringRequiredReturns
Promise
Promise<void>RequiredsetPassword_
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
userId
stringRequiredpassword
stringRequiredReturns
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
userId
stringRequiredReturns
Promise
Promise<string>Required