I don’t want the lightbox sign up to show when their is an error. Can someone help ?
there is a video to show the problem:
I don’t want the lightbox sign up to show when their is an error. Can someone help ?
there is a video to show the problem:
Why are you adding this bit here in the red frame into the login code?
That is trying to happen before the code has finished logging the user in.
The code will simply try to move the user onto the pages marked in your Wix Location to functions if they are the certain emails, so the code below will never be run and the user will never be logged in through the Wix Users login function.
Your login code should look like this below where you move the user onto another page after the user has finished being logged in.
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
$w.onReady(function () {
$w("#forgotPassword").onClick( (event) => {
//wixWindow.lightbox.close()
wixUsers.promptForgotPassword()
.then( ( ) => {
//
} )
.catch( (err) => {
let errorMsg = err; //"The user closed the forgot password dialog"
});
});
});
export function loginButton_click(event) {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email, password)
.then( () => {
console.log("User is logged in");
wixLocation.to("/account/my-account"); //Change the URL ending to whatever page you want to send the user to after they log in.
} )
.catch( (err) => {
console.log(err);
$w("#errorMessage").expand(); // You can delete this line if you are not going to add an error message. Use a regular text element set to 'collapse on load' from the Properties Panel.
} );
}
Thanks for the reply, I add this line of code because when my user logs in I want him to be redirected to his page.
Well done