To set up a password rest button using ForgotPasswordPrompt().
Note: for the function to work the user has to be logout.
Also, the page permission has to be “anyone”, if it sets to members only then login page will open and won’t allow the user to rest the password.
@yisrael-wix I hope to document this in API reference - it would saved me time
import wixUsers from 'wix-users';
//...
$w.onReady(function () {
passwordReset();
});
//...
function passwordReset () {
wixUsers.promptForgotPassword()
.then( ( ) => {
console.log("Password reset submitted");
} )
.catch( (err) => {
let errorMsg = err; // "The user closed the forgot password dialog"
} );
}
export function btnResetPass_click(event) {
if (wixUsers.currentUser.loggedIn) {
wixUsers.logout()
.then (() => {
passwordReset();
});
}
passwordReset();
}
How You Can Built It
Page Elements:
1. Add a button (rename id: btnResetPass)
Code
In the page tab use the above code
APIs We Used
wixUsers
After many trials and errors this is my first post.
Enjoy!