Skip to main content

Class: AuthService

Can authenticate a user based on email password combination

Hierarchy

  • "medusa-interfaces"

    AuthService

Constructors

constructor

new AuthService(__namedParameters)

Parameters

NameType
__namedParametersObject

Overrides

BaseService.constructor

Defined in

services/auth.ts:12

Methods

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

NameTypeDescription
emailstringthe email of the user
passwordstringthe password of the user

Returns

Promise<AuthenticateResult>

success: whether authentication succeeded user: the user document if authentication succeded error: a string with the error message

Defined in

services/auth.ts:78


authenticateAPIToken

authenticateAPIToken(token): Promise<AuthenticateResult>

Authenticates a given user with an API token

Parameters

NameTypeDescription
tokenstringthe api_token of the user to authenticate

Returns

Promise<AuthenticateResult>

success: whether authentication succeeded user: the user document if authentication succeded error: a string with the error message

Defined in

services/auth.ts:41


authenticateCustomer

authenticateCustomer(email, password): Promise<AuthenticateResult>

Authenticates a customer based on an email, password combination. Uses scrypt to match password with hashed value.

Parameters

NameTypeDescription
emailstringthe email of the user
passwordstringthe password of the user

Returns

Promise<AuthenticateResult>

success: whether authentication succeeded user: the user document if authentication succeded error: a string with the error message

Defined in

services/auth.ts:123


comparePassword_

comparePassword_(password, hash): Promise<boolean>

Verifies if a password is valid given the provided password hash

Parameters

NameTypeDescription
passwordstringthe raw password to check
hashstringthe hash to compare against

Returns

Promise<boolean>

the result of the comparison

Defined in

services/auth.ts:28