Hi I have an issue where by if I click the the "X" on the window that opens after I click on the " sign in" button, it is showing me the screen that I should only see if I am logged in. Please can someone help me fix this urgently? I have included the code I used.
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#loginButton1").label = "Logout";
$w("#winners").show();
$w("#text6").hide();
$w("#html1").show();
$w("#hot").show();
}
else {
$w("#loginButton1").label = "Sign in";
$w("#winners").hide();
$w("#text6").show();
$w("#html1").hide();
$w("#hot").hide();
}
} );
export function loginButton1_click(event) {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w("#loginButton1").label = "Login";
$w("#winners").hide();
$w("#text6").show();
$w("#hot").hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
// update buttons accordingly
$w("#loginButton1").label = "Logout";
$w("#winners").show();
$w("#text6").hide();
$w("#html1").show();
$w("#hot").show();
}
}
I would suggest that you use the tutorial correctly as you have missed out a large chunk of the code for this page.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area