AuthService
Can authenticate a user based on email password combination
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
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
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>Requiredthe transactional work to be done
isolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Potential error handler
Returns
Promise
Promise<TResult>Requiredthe result of the transactional work
authenticate
Authenticates a given user based on an email, password combination. Uses scrypt to match password with hashed value.
Parameters
email
stringRequiredthe email of the user
password
stringRequiredthe password of the user
Returns
Promise
Promise<AuthenticateResult>Requiredsuccess: whether authentication succeeded
user: the user document if authentication succeeded
error: a string with the error message
authenticateAPIToken
Authenticates a given user with an API token
Parameters
token
stringRequiredthe api_token of the user to authenticate
Returns
Promise
Promise<AuthenticateResult>Requiredsuccess: whether authentication succeeded
user: the user document if authentication succeeded
error: a string with the error message
authenticateCustomer
Authenticates a customer based on an email, password combination. Uses scrypt to match password with hashed value.
Parameters
email
stringRequiredthe email of the user
password
stringRequiredthe password of the user
Returns
Promise
Promise<AuthenticateResult>Requiredsuccess: whether authentication succeeded
customer: the customer document if authentication succeded
error: a string with the error message
comparePassword_
Verifies if a password is valid given the provided password hash
Parameters
password
stringRequiredthe raw password to check
hash
stringRequiredthe hash to compare against
Returns
Promise
Promise<boolean>Requiredthe result of the comparison
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanwithTransaction
Parameters
transactionManager
EntityManagerReturns
AuthService
objectRequiredCan authenticate a user based on email password combination
Was this section helpful?