Frontend API
Methods to recover a customer's account login credentials by sending them a password reset email.
Use the recover method to send an email to the customer with a link to reset their password. If the email address provided doesn't exist in the system, no email will be sent.
Returns a value indicating success.
await swell.account.recover({
email: 'julia@example.com'
})
To customize the password reset URL sent to the customer in an email, pass the optional parameter reset_url, including a placeholder for the password reset key: {reset_key}. Swell will automatically generate and substitute the password reset key in the URL before sending an email.
await swell.account.recover({
email: 'julia@example.com',
reset_url: 'https://example.com/password-reset?key={reset_key}'
})
Password reset requests automatically expire after 24 hours.
Use to set the customer's new password. This requires the reset_key from the recovery email (see above). The password recovery email should link to your storefront with reset_key as a URL parameter that you can pass to this method.
await swell.account.recover({
password: 'thenewpassword',
reset_key: 'e42e66fc7e3f00e9e179w20ad1841146'
})
Methods to recover a customer's account login credentials by sending them a password reset email.
Send a password reset email
Send a customized password reset URL to the customer to reset their password. Swell will automatically generate and substitute the password reset key in the URL before sending an email. If the email address provided doesn't exist in the system, no email will be sent.
Returns a value indicating success. The parameters for the sendAccountRecovery mutation are email (required) and passwordResetUrl (required).
mutation sendAccountRecovery {
sendAccountRecovery(
email: "ancotar@fortcaractacus.net"
passwordResetUrl: "https://example.com/password-reset?key={reset_key}"
) {
success
}
}Password reset requests automatically expire after 24 hours.
Reset an account password
Set up a new password for the customer. This requires the reset_key from the recovery email (see above). The password recovery email should link to your storefront with reset_key as a URL parameter that you can pass to this method.
Returns a value indicating success. The parameters for the recoverAccount mutation are password (required) and passwordResetKey (required).
mutation {
recoverAccount(
password: "thenewpassword"
passwordResetKey: "e42e66fc7e3f00e9e179w20ad1841146"
) {
success
}
}