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 settings → Authentication view of Designer.
- If the email of the user has not been verified yet, this method will return an error object.
- Javascript
- Dart
let email = "[email protected]";
// Send reset password email
const { errors } = await altogic.auth.sendResetPwdEmail(email);
final email = "[email protected]";
// Send reset password email
final errors = await altogic.auth.sendResetPwdEmail(email);
See documentation for how to handle redirect link with Flutter.
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 settings → Authentication view of Designer. Additionally you can override this value in your Environment details view for each environment.
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 |
---|---|---|---|---|
1 | String | Yes | The 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.
- Javascript
- Dart
let accessToken = "0e55c6fa93ae4e8cb11b35";
let newPassword = "123456%";
// Reset password of the user with the `newPassword`
const { errors } = await altogic.auth.resetPwdWithToken(
accessToken,
newPassword
);
final accessToken = "0e55c6fa93ae4e8cb11b35";
final newPassword = "123456%";
// Reset password of the user with the `newPassword`
final errors = await altogic.auth.resetPwdWithToken(
accessToken,
newPassword
);
Parameters
Here you can find parameters for the resetPwdWithToken
method.
# | Name | Data type | Required | Description |
---|---|---|---|---|
1 | accessToken | String | Yes | The access token that is retrieved from the redirect URL query string parameter. |
2 | newPassword | String | Yes | The 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 settings → Authentication view of Designer.
- If the phone number of the user has not been verified yet, this method will return an error object.
- Javascript
- Dart
let phone = "+15555555555";
// Send reset password email
const { errors } = await altogic.auth.sendResetPwdCode(phone);
final phone = "+15555555555";
// Send reset password email
final 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 |
---|---|---|---|---|
1 | phone | String | Yes | The 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.
- Javascript
- Dart
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
);
final phone = "+15555555555";
final code = "432987";
final newPassword = "123456%";
// Reset password of the user with the `newPassword`
final errors = await altogic.auth.resetPwdWithCode(
phone,
code,
newPassword
);
Parameters
Here you can find parameters for the resetPwdWithCode
method.
# | Name | Data type | Required | Description |
---|---|---|---|---|
1 | phone | String | Yes | The phone number of the user. |
1 | code | String | Yes | The SMS code that is sent to the phone of the user. |
2 | newPassword | String | Yes | The new password of the user. |