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
EntityManagerEntityManagerRequiredInherited 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.
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
PromisePromise<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
emailstringRequiredpasswordstringRequiredReturns
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
tokenstringRequiredReturns
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
emailstringRequiredpasswordstringRequiredReturns
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
passwordstringRequiredhashstringRequiredReturns
Promise<boolean>
PromisePromise<boolean>Requiredthe result of the comparison
PromisePromise<boolean>RequiredshouldRetryTransaction_
Protected shouldRetryTransaction_(err): boolean
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanInherited from
TransactionBaseService.shouldRetryTransaction_
withTransaction
withTransaction(transactionManager?): AuthService
Parameters
transactionManagerEntityManager