Skip to main content

Reset Password

Send reset password email

If your users are authenticated using their email and password, you can send reset password email to a user by calling the sendResetPwdEmail method.

note

This method works only if email confirmation is enabled in your App settingsAuthentication view of Designer.

  • If the email of the user has not been verified yet, this method will return an error object.
let email = "[email protected]";

// Send reset password email
const { errors } = await altogic.auth.sendResetPwdEmail(email);

When the user clicks on the link in email, Altogic verifies the validity of the reset-password link and if successful redirects the user to the Redirect URL with an access token in a query string parameter named access_token.

tip

You can define the Redirect URL in your App settingsAuthentication view of Designer. Additionally you can override this value in your Environment details view for each environment.

http://localhost:3001/auth-redirect?access_token=0e55c6fa93ae4e8cb11b35&action=reset-pwd
note

At this stage your app needs to detect action=reset-pwd in the Redirect URL and display a password reset form to the user.

After getting the new password from the user, you can call the resetPwdWithToken method with the access token and new password to reset the password of the user.

Parameters

Here you can find parameters for the sendResetPwdEmail method.

#

Name

Data type

Required

Description

1emailStringYesThe email address of the user who wants to reset the password.

Reset password with token

You can reset password of the user by calling the resetPwdWithToken method. It resets the password of the user by using the access token provided through the sendResetPwdEmail method.

let accessToken = "0e55c6fa93ae4e8cb11b35";
let newPassword = "123456%";

// Reset password of the user with the `newPassword`
const { errors } = await altogic.auth.resetPwdWithToken(
accessToken,
newPassword
);

Parameters

Here you can find parameters for the resetPwdWithToken method.

#

Name

Data type

Required

Description

1accessTokenStringYesThe access token that is retrieved from the redirect URL query string parameter.
2newPasswordStringYesThe new password of the user.

Send reset password code

If your users are authenticated using their phone number and password, you can send reset password SMS code to a user by calling the sendResetPwdCode method.

note

This method works only if phone confirmation is enabled in your App settingsAuthentication view of Designer.

  • If the phone number of the user has not been verified yet, this method will return an error object.
let phone = "+15555555555";

// Send reset password email
const { errors } = await altogic.auth.sendResetPwdCode(phone);
note

After sending the SMS code, you need to display a password reset form to the user. When you get the new password from the user, you can call resetPwdWithCode method with the phone number of the user, SMS code and new password.

Parameters

Here you can find parameters for the sendResetPwdCode method.

#

Name

Data type

Required

Description

1phoneStringYesThe phone number of the user who wants to reset the password.

Reset password with code

You can reset password of the user by calling the resetPwdWithCode method. It resets the password of the user by using the SMS code provided through the sendResetPwdCode method.

let phone = "+15555555555";
let code = "432987";
let newPassword = "123456%";

// Reset password of the user with the `newPassword`
const { errors } = await altogic.auth.resetPwdWithCode(
phone,
code,
newPassword
);

Parameters

Here you can find parameters for the resetPwdWithCode method.

#

Name

Data type

Required

Description

1phoneStringYesThe phone number of the user.
1codeStringYesThe SMS code that is sent to the phone of the user.
2newPasswordStringYesThe new password of the user.