Skip to main content

Change Email

Change email

You can change email of the user by calling the changeEmail method.

let currentPassword = "123456";
let newEmail = "[email protected]";

// Change email of the user
const result = await altogic.auth.changeEmail(currentPassword, newEmail);
Example response
{
"user": {
"_id": "6235f78c0874df80013caea2",
"provider": "altogic",
"providerUserId": "6235f78c0874df80013caea2",
"email": "[email protected]",
"signUpAt": "2022-03-19T15:32:28.958Z",
"lastLoginAt": "2022-03-19T15:38:42.093Z",
"emailVerified": true,
"name": "Rooby"
},
"errors": null
}
info

If email confirmation is enabled in your App settingsAuthentication view of Designer

  • It sends a confirmation email to the new email address with a link for the user to click and returns the current user's info.
  • Until the user clicks on the link, the user's email address will not be changed to the new one.
  • Once user click on the link, the user's email address will be changed to the new one and redirect user to the Redirect URL with an action=change-email query string parameter.
http://localhost:3001/auth-redirect?access_token=0e55c6fa93ae4e8cb11b35&action=change-email
note

If email confirmation is disabled in your App settingsAuthentication view of Designer, it immediately updates the user's email and returns back the updated user data.

Example response
{
"user": {
"_id": "6235f78c0874df80013cae22",
"provider": "altogic",
"providerUserId": "6235f78c0874df80013caea2",
"email": "[email protected]",
"signUpAt": "2022-03-19T15:32:28.958Z",
"lastLoginAt": "2022-03-19T15:38:42.093Z",
"emailVerified": false,
"name": "Rooby"
},
"errors": null
}

Parameters

Here you can find parameters for the changeEmail method.

#

Name

Data type

Required

Description

1currentPasswordStringYesThe current password of the user.
2newEmailStringYesThe new email address of the user.
note

An active user session is required (e.g., user needs to be logged in) to call this method.