Lightbox catch error

I have created a simple “Custom Log In / Sign On Screen” using the code below.
Works fine, but it seems the catch error is not working, because nothing happens when typing wrong email/password. The error message is still hidden.
But when typing in correct info, it works fine.
What is wrong, any idea?
Thanks:-)

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.
} );
}

yes i had that same issue i hope someone can fix that issue

Your code looks fine so the problem is probably somewhere else.
It’s hard to guess. Maybe you made the text message hidden on load instead of collapsed (or something else).

here is the video for my problem once i activate my code it should come up with an error massage because i enter the wrong password i don’t why is

my error massage is not coming up and also the login button is not redirecting me to my account i dont know why can someone help me with this is it because i am using a light box that why is not working. here is the code that i activate

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( '/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. 

} );

}

@thavachelvam1970 I can see in this video that I was right. You made the errorMessage hidden on load instead of collapsed.
Change it, and it will work.

Do I change hidden on load to collapsed

@jonatandor35 thank you soo much for helping me now it is displaying the error massage i think i know what i did wrong i should change hidden to collapsed and also the last mistaken was that i should put
let email = $w( “#email” ).value;

let password = $w( “#password” ).value;

and after password = $w( “#password” ).value; the next one is an error massage
$w( “#errorMessages1” ).expand();

@J.D. you are best corvid ever and also have an awesome weekend.

2 Likes