AuthService
Can authenticate a user based on email password combination
Constructors
constructor
**new AuthService**(«destructured»)
Parameters
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>manager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequiredAccessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManagerEntityManagerRequiredMethods
atomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter 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>Requiredauthenticate
**authenticate**(email, password): Promise<[AuthenticateResult](/references/services/types/AuthenticateResult)>
Authenticates a given user based on an email, password combination. Uses scrypt to match password with hashed value.
Parameters
emailstringRequiredpasswordstringRequiredReturns
Promise<AuthenticateResult>
authenticateAPIToken
**authenticateAPIToken**(token): Promise<[AuthenticateResult](/references/services/types/AuthenticateResult)>
Authenticates a given user with an API token
Parameters
tokenstringRequiredReturns
Promise<AuthenticateResult>
authenticateCustomer
**authenticateCustomer**(email, password): Promise<[AuthenticateResult](/references/services/types/AuthenticateResult)>
Authenticates a customer based on an email, password combination. Uses scrypt to match password with hashed value.
Parameters
emailstringRequiredpasswordstringRequiredReturns
Promise<AuthenticateResult>
comparePassword_
Protected **comparePassword_**(password, hash): Promise<boolean>
Verifies if a password is valid given the provided password hash
Parameters
passwordstringRequiredhashstringRequiredReturns
Promise<boolean>
PromisePromise<boolean>RequiredshouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanwithTransaction
**withTransaction**(transactionManager?): [AuthService](/references/services/classes/AuthService)
Parameters
transactionManagerEntityManager