I created login by custom lightbox with button link to my custom registration page. When I previewed it, it worked so fine but once I view on the publish site, it calls ‘reset password’ (I can show you just login page) screen and i have to close it first for redirect to the custom page I’ve made. Please check on my site: https://www.oraratcooking.com/
See below for code i put on login light box
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
$w.onReady(function () {
$w("#registerButton").onClick( (event) => {
wixLocation.to("/register")
});
//$w("#forgetPassword").onClick( (event) => { //I try to comment this out it still call the reset password page.
//wixWindow.lightbox.close()
// wixUsers.promptForgotPassword()
// .then( ( ) => {
//
// } )
// .catch( (err) => {
// let errorMsg = err; //"The user closed the forgot password dialog"
// });
//});
});
export function loginButton_click_1(event) {
if ($w("#input1").valid && $w("#input2").valid) {
let email = $w("#input1").value;
let password = $w("#input2").value;
wixUsers.login(email, password)
.then( () => {
console.log("User is logged in");
wixWindow.lightbox.close()
wixLocation.to("/home"); //Change the URL ending to whatever page you want to send the user to after they log in.
} )
.catch( (err) => {
console.log(err);
$w("#emailExist").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.
} );
} else {$w('#errormessage').show(); //This is were we prompt the message to show up again ONLY if there is an error
console.log("Missing information"); //You can change the text of this line or delete it
}
}
Now i can solve this issue, I found my code error on my registration page which call function prompt forget password. Once i removed this code it resolved. But now I face with the new issue on login and about to find out.
You don’t actually need this line of code here.
$w("#registerButton").onClick( (event) => {
wixLocation.to("/register")
});
Just simply have the text box element itself linked to your signup lightbox.
So in theory it should just be…
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( ( ) => {
//rest of code//
That is exactly what I have done on a site with login and signup lightboxes.
Login Lightbox to another page.
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;
});
});
});
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");
} )
.catch( (err) => {
console.log(err);
$w("#errorMessage").expand();
} );
}
Login Lightbox with page reload
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;
});
});
});
export function loginButton_onclick(event) {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email, password)
.then( () => {
console.log("User is logged in");
wixWindow.lightbox.close();
wixLocation.to(wixLocation.url);
} )
.catch( (err) => {
console.log(err);
$w("#errorMessage").expand();
} );
}
Hi, I realize this is an older post but would like to ask how to deal with privacy when coding this? Anything special to comply with privacy legislation?