changePassword
Reset a user's password with a one-time code. Not available on the Launch and Study plans.
Description
Sets a new password for the user identified by userIdentifier, using the one-time code from generateCode(). No user session is needed: the code proves ownership of the account. On success, resolves to true and ends all the user's sessions for this provider, so the user has to sign in again with auth(). On the Launch and Study plans the API returns 405.
.changePassword(
,
,
,
,
,
,
);
Parameters schema
Schema
marker(required): string
Marker of the auth provider.
example: "email"
userIdentifier(required): string
Identifier (login) of the user, such as an email address.
example: "john@example.com"
eventIdentifier(required): string
Marker of a Change password form event in the Events module. The platform uses it to notify the user after the change. It doesn't have to match the event passed to generateCode.
example: "reg"
type(required): number
Operation type, 1 or 2. The platform doesn't use it yet: only resetting the password with a code is supported.
example: 1
code(required): string
One-time code the user received.
example: "123456"
newPassword(required): string
New password.
example: "newPassword123"
repeatPassword: string
New password repeated for confirmation. Optional.
example: "newPassword123"
Examples
Minimal example
// The code comes from AuthProvider.generateCode('email', 'john@example.com', 'user_registration').
// 'password_changed' is the marker of a "change password" event that notifies the user.
const response = await AuthProvider.changePassword(
'email',
'john@example.com',
'password_changed',
1,
'123456',
'newPassword123',
'newPassword123'
);
Example response
true
Try it live
Run this method in the JS SDK sandbox. Connect your Project URL and App Token on first visit, then open:
- Password reset: reset the user's password after verifying the code they received via email or SMS.