AuthService
Can authenticate a user based on email password combination
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
authenticate
authenticate(email
, password
): Promise
<AuthenticateResult
>
Authenticates a given user based on an email, password combination. Uses scrypt to match password with hashed value.
Parameters
email
stringRequiredpassword
stringRequiredReturns
Promise
<AuthenticateResult
>
success: whether authentication succeeded
user: the user document if authentication succeeded
error: a string with the error message
authenticateAPIToken
authenticateAPIToken(token
): Promise
<AuthenticateResult
>
Authenticates a given user with an API token
Parameters
token
stringRequiredReturns
Promise
<AuthenticateResult
>
success: whether authentication succeeded
user: the user document if authentication succeeded
error: a string with the error message
authenticateCustomer
authenticateCustomer(email
, password
): Promise
<AuthenticateResult
>
Authenticates a customer based on an email, password combination. Uses scrypt to match password with hashed value.
Parameters
email
stringRequiredpassword
stringRequiredReturns
Promise
<AuthenticateResult
>
success: whether authentication succeeded
customer: the customer document if authentication succeded
error: a string with the error message
comparePassword_
Protected
comparePassword_(password
, hash
): Promise
<boolean
>
Verifies if a password is valid given the provided password hash
Parameters
password
stringRequiredhash
stringRequiredReturns
Promise
<boolean
>
Promise
Promise<boolean>Requiredthe result of the comparison
Promise
Promise<boolean>RequiredshouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
withTransaction
withTransaction(transactionManager?
): AuthService
Parameters
transactionManager
EntityManager