Wix Login Lightbox No Longer Working. Live Site

Suddenly sometime in the past week my login lightbox/ button that has worked without issues for months is not working. I have to refresh the page and then i am logged in. Not sure why this is happening suddenly. Can anyone see anything strange in my code or make sense of the console error logs that can give me any input on what is wrong. Live site URL is www.cryptodynamics.info/home

import wixUsers from ‘wix-users’;
import wixLocation from “wix-location”;
import wixWindow from ‘wix-window’;

$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w(" #button2 ").label = “Logout”;

}
else {
$w(“#button2”).label = “Login”;

}
} );
export function button2_click() {
//Add your code for this event here:
let email = $w(" #email “).value;
let password = $w(” #password ").value;

wixUsers.login(email, password)
.then( () => {
console.log(“User is logged in”);
} )
.catch( (err) => {
console.log(err);

} );

wixWindow.lightbox.close(); //–Doesn’t seem like the code is reaching here
wixLocation.to(“/account/my-account”)
console.log
}

export function forgot_click() {
wixUsers.promptForgotPassword();
}

1 Like

13 views and not a single response from Wix in over 2 weeks that a live site is down and support has no clue either. Why does this not surprise me. Where do you get this statement " Wix.com is a leading cloud-based development platform" when you can’t even keep the most basic functions working?

1 Like

All you need to do is to have your custom login lightbox refresh the page it is opened on after it closes so that the code on your page is kicked into gear, just exactly as you mentioned and told yourself the answer in your post above!

I have similar on my members only page where I have only my logo and a login button showing if members are not logged in.

Without my custom login lightbox refreshing the members only page once the member has logged themselves in and the login lightbox closes, then the page will not work as the code won’t be called for the logged in user and the person will actually be logged in, however the page won’t change from login to logout etc as the code is not started.

This is my own custom login lightbox code that closes and refreshes my members only page after the user logs in and the lightbox closes.

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_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);  //This reloads the same page and allows code to show hidden member parts.
   } )
    .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.
   } ); 
}

This is my page code for my members only page, this is where my login button is situated and when the user clicks on login, my custom login lightbox opens and the user logs themselves in and the lightbox closes and refreshes my members only page, which then kicks the code into working and changes the values of the page and the login button value becomes logout and all my hidden member parts are now shown as well.

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#loginbutton").label = "Logout";
$w("#membersareaonlystrip").expand();
$w("#whitegapforfooter").hide();

}
else {
$w("#loginbutton").label = "Login";
$w("#membersareaonlystrip").collapse();
$w("#whitegapforfooter ").show();

}
} );

export function loginbutton_onclick(event) { 
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w("#loginbutton").label = "Login";
  $w("#membersareaonlystrip").collapse();
  $w("#whitegapforfooter ").show();

} );
}
// user is logged out
else {
let userId;
let userEmail;

// prompt the user to log in 
wixUsers.promptLogin( {"mode": "signup"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("Members")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("Members", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#loginbutton").label = "Logout";
 $w("#membersareaonlystrip").expand();
$w("#whitegapforfooter").hide();

} )
.catch( (err) => {
console.log(err);
} );
}
}

export function profilebutton_onclick(event) {
wixLocation.to(`/Members/${wixUsers.currentUser.id}`); 
}

export function entermembersbutton_onclick(event) {
wixLocation.to(`/members-area`); 
}

export function myaccountbutton_onclick(event) {
wixLocation.to(`/account/my-account`); 
}

export function websiteupdatebutton_onclick(event) {
wixLocation.to(`/website-update`); 
}

I have removed everything from the login code down to this, barebones basic login. And it DOES NOT WORK! It did until 2 weeks ago when Corvid rolled out.

import wixUsers from ‘wix-users’;
import wixLocation from “wix-location”;
import wixWindow from ‘wix-window’;

export function button2_click() {

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

wixUsers.login(email, password)
.then( () => {
console.log(“User is logged in”);
wixWindow.lightbox.close(); //–New location
wixLocation.to(“/account/my-account”)
console.log
} )
. catch ( (err) => {
console.log(err);

});

console.log(“Made it to lightbox close”);
}

export function forgot_click() {
wixUsers.promptForgotPassword();
}

Well just swap your login lightbox code to what I use and it should all work fine again. I am not saying your code is wrong in anyway as you state that it was working fine before they had the Wix Turbo and Wix Code to Wix Corvid change of name.

I am simply giving you another option to fix this as my custom login and signup lightboxes were made up over a year ago now and the code for both of them hasn’t changed , nor has it needed to be changed after any changes by Wix like the Wix Turbo rollout or the change in name to Wix Corvid. My code for both lightboxes has been working fine non-stop.

However, the Wix Code name change to Wix Corvid shouldn’t have had any effect on your working code as it was only a name change and nothing in the code should have been affected.

The only thing that I have noticed in your final code above in your latest post, is that you haven’t got a onReady call at the start of your code underneath the imports, you’ve just gone from your imports straight into your button onclick events.

My forgot password is just a one line text element on the lightbox which simply says ‘Forgot Password’, which when they click on it, it then takes them to the Wix Forgot Password window (eventually we will be able to do our own design like login/signup lightboxes.)

Apart from the forgot password text line, the only things I have on my login lightbox are my logo and the user inputs for email and password. Plus, I also have another one line text element which is just a simple link through the element itself to my custom signup lightbox just in case they wish to register instead

Your choice if you want to change anything, however if you are still struggling with getting yours to work, then I would suggest just trying it to see if it works for yourself too. This would then give you time to see if you can play around and get your original code reworking, without having to have the worry of your code not working on your website whilst you work on a fix.

Obviously you will need to change in your code

//from this
wixLocation.to(wixLocation.url); 
//to this
wixLocation.to(`/account/my-account`); 

My custom login lightbox code again:

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_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);  //This reloads the same page and allows code to show hidden member parts.
   } )
    .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.
   } ); 
}

Hi,
It seems like an issue or our end. We’re looking into it.

@givemeawhisky I just tried your code, no change at all. I don’t know what the issue is exactly other than the promise is not resolving after the user logs in, and that causes a cascade of errors and issues with my site. Been dealing with Wix support for 2 weeks, after first having them tell me MY code is wrong, NOT! Now they say they don’t know what is going on, that it will be brought up with product development. In the mean time i am 3 weeks late launching this site (can’t even do terminal testing cause the login system doesn’t work) and i have partners that are talking about pulling out of the project because they are no longer confident that Wix is a platform that can even support a “REAL” business site. FML.

@dragonlord4469187 I have been checking out your site. However, the code I see on your site — specifically, the code on your “Login” lightbox page — does not seem to correspond to the published version. So I’m having a bit of difficulty trying to precisely reproduce the issues you’re encountering. Can you try to fix up the code a bit and then re-publish so I can see more clearly what is happening?

That said, it appears that some behaviors around lightboxes have changed a bit with the release of Turbo. I noted in particular that if you have a lightbox assigned as your custom signup form, there are some problems when you log out. This is clearly a bug. It may (or may not) be related to the errors you’re seeing as well.

Keep me apprised. Thanks.

Late-breaking news — I discovered the problem! There is definitely a bug on our end; those errors should not be appearing, and worse, your site basically becomes inaccessible as most code and controls no longer function. I will send this information to our developers.

However, it kind of makes sense that it doesn’t work under Turbo, and it’s curious that it worked before. Here’s the issue: On the “Login” lightbox page, you configured the “Submit” button to go to the “My Account” page as soon as it is clicked. The problem is that there is asynchronous code that also executes when you click that button. Those actions are attempting to execute in parallel and, well, it doesn’t seem to like that…

The fix: simply configure the “Submit” button to not navigate to another page when it is clicked, and let the code do the navigation (as it’s already configured to do). Once you do that, the errors should disappear and your site should work as before.

Let me know how it goes!

p.s. Just an FYI: the reason that you saw the “Made it to lightbox close” message is because it executes before the asynchronous login function had a chance to complete. So you see the message before all hell breaks loose…

@chaim-kram Ok, changing the button. Doing this now.

@chaim-kram That worked!! Still getting a few errors in console but it is working now.

1 Like

Great! Actually, one of those errors above is a different bug that other users reported and is already being fixed… :wink:

BTW I tested this under our old pre-Turbo system. Even though it didn’t generate the errors and your site functioned basically correctly, I noticed that the asynchronous code that was supposed to execute after the login never actually executed. So there you go…

I know the SDK Warning for the “btnPreDash1” that is because of the site code that will not run on a lightbox. Thank you so much for helping get this taken care of. Seriously, lifesaver!

1 Like

@chaim-kram There is still one issue, and that is when a user logs out on a member restricted page it opens the login/signup lightbox but it seems to break the lightbox formating. On non-member restricted pages it just logs out like it should.

how it looks when user logs out on a member restricted page


how it should look

Yes, I noticed this too and will log this into our bug reporting system as well. This is also a bug that appears only with Turbo. Thanks for the information!

1 Like