Hi Wix team,
In some of site pages, I need to check if user already was logged in.
If user is not logged in, I want to show them "Login screen".
I write something like that to do so:
$w.onReady(function () { if(!users.currentUser.loggedIn) { console.log("User is required to log-in"); $w("#button1").label = "Log in"; return users.promptLogin() .then( (res) => { console.log("Sucessfully logged in"); }) .catch( (err) => { console.log("Closed login screen"); }); } $w("#button1").label = "Log out"; console.log("User already logged in"); }); On desktop, the login screen is shown as expected, while on mobile I see only blank screen with close "X" at right upper corner.
Is there some known issue related to mobile login?
Test page for reference: https://dmitrybi32.wixsite.com/issue-reproduce/about
Thanks.
Hi Dima,
We discovired a few anomalies when triggering the login prompt in mobile.
I will update this thread once we have feedback regarding the mater.
In the meanwhile as a workaround you can set the page as member only, which will trigger the login prompt automatically. This way you can be sure that wixUsers.currentUser.loggedIn will always return true.
Hi Tal,
I checked out the article, the difference I find is that wixUsers.promptLogin is called there without "return".
// prompt the user to log in wixUsers.promptLogin( {"mode": "login"} ) .then( (user) => { ...
Indeed if I remove "return" before login prompt function, login screen displayed on mobile as expected.
However it exposes undesired effect - the page is shown for some time before actual login screen appears.
In older forum discussion, Yoav wrote the following note:
"Note that in both cases we make sure to return the promises from the $w.onReady function. This makes sure we complete the processing before the page is displayed to the user." (https://www.wix.com/code/home/forum/community-discussion/wix-users-api)
This is the reason why I need the wixUsers.promptLogin to be called like
return wixUsers.promptLogin(...)
And here I'm back to the original issue - with "return" before promptLogin , on mobile, login page appears blank...
Thanks,
Dima
Hi,
I recommend following this article which explains how to create a login page.
Best,
Tal.