Hello,
On my custom login, the error message is not appearing when an incorrect login is triggered.
Everything else works fine except for that. I think it’s in the wrong place in the code, but I do not know anything about coding and have gotten the code from a tutorial. Can someone fix my code and send it back to me? Thank you so much if you can!
Here is the code:
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( “#loginEmail” ).value;
let password = $w( “#loginPassword” ).value;
wixUsers.login(email, password)
.then( () => {
console.log( “User is logged in” );
wixLocation.to( “/login” ); //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.
} );
}
$w.onReady( function () {
$w( “#loginPassword” ).onKeyPress( (event) => {
let key = event.key; // “Enter”
let email = $w( “#loginEmail” ).value;
let password = $w( “#loginPassword” ).value;
wixUsers.login(email, password)
.then( () => {
console.log( “User is logged in” );
wixLocation.to( “/login” ); //Change the URL ending to whatever page you want to send the user to after they log in.
} )
} )
} );
$w.onReady( function () {
$w( “#loginEmail” ).onKeyPress( (event) => {
let key = event.key; // “Enter”
let email = $w( “#loginEmail” ).value;
let password = $w( “#loginPassword” ).value;
wixUsers.login(email, password)
.then( () => {
console.log( “User is logged in” );
wixLocation.to( “/login” ); //Change the URL ending to whatever page you want to send the user to after they log in.
} )
} )
} );