Skip to main content
Skip to main content

AuthService

Can authenticate a user based on email password combination

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
customerService_CustomerServiceRequired
manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
userService_UserServiceRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

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

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

PromisePromise<TResult>Required
the 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

emailstringRequired
the email of the user
passwordstringRequired
the password of the user

Returns

PromisePromise<AuthenticateResult>Required
success: 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

tokenstringRequired
the api_token of the user to authenticate

Returns

PromisePromise<AuthenticateResult>Required
success: 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

emailstringRequired
the email of the user
passwordstringRequired
the password of the user

Returns

PromisePromise<AuthenticateResult>Required
success: 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

passwordstringRequired
the raw password to check
hashstringRequired
the hash to compare against

Returns

PromisePromise<boolean>Required
the result of the comparison

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

withTransaction

Parameters

transactionManagerEntityManager

Returns

AuthServiceobjectRequired
Can authenticate a user based on email password combination
Was this section helpful?