Class: AuthService
Can authenticate a user based on email password combination
Hierarchy
"medusa-interfaces"
↳
AuthService
Constructors
constructor
• new AuthService(__namedParameters
)
Parameters
Name | Type |
---|---|
__namedParameters | Object |
Overrides
BaseService.constructor
Defined in
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
Name | Type | Description |
---|---|---|
email | string | the email of the user |
password | string | the 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
authenticateAPIToken
▸ authenticateAPIToken(token
): Promise
<AuthenticateResult
>
Authenticates a given user with an API token
Parameters
Name | Type | Description |
---|---|---|
token | string | the 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
authenticateCustomer
▸ authenticateCustomer(email
, password
): Promise
<AuthenticateResult
>
Authenticates a customer based on an email, password combination. Uses scrypt to match password with hashed value.
Parameters
Name | Type | Description |
---|---|---|
email | string | the email of the user |
password | string | the 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
comparePassword_
▸ comparePassword_(password
, hash
): Promise
<boolean
>
Verifies if a password is valid given the provided password hash
Parameters
Name | Type | Description |
---|---|---|
password | string | the raw password to check |
hash | string | the hash to compare against |
Returns
Promise
<boolean
>
the result of the comparison