Hi everyone,
I’ve set up a custom login/logout bar (not the default accountNavBar) and it’s working just fine. By clicking on ‘Inloggen’ (It’s in Dutch) my custom login lightbox pops up and i’m logged in and redirected to my private member page. When logging out, I am logged out. But the only problem I’m having is that the default loginpage pops up as soon as I log out. I found a code that should redirect to my home page after logging out, but I can’t seem to get it to work. Could someone please tell me what is wrong about my code? The ‘textInloggen’ and ‘textMijnAccount’ are actually buttons.
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;
import wixWindow from ‘wix-window’
$w.onReady( () => {
$w( “#button5” ).onMouseIn((event) => {
$w( ‘#boxInloggen’ ).expand();
});
$w( "#boxInloggen" ).onMouseOut((event) => {
$w( '#boxInloggen' ).collapse();
})
if (wixUsers.currentUser.loggedIn) {
$w( “#textInloggen” ).label = “Uitloggen” ;
$w( “#textMijnAccount” ).expand();
}
else {
$w( “#textInloggen” ).label = “Inloggen” ;
$w( “#textMijnAccount” ).collapse();
}})
export function textInloggen_onClick() {
if (wixUsers.currentUser.loggedIn) {
wixUsers.logout();{
$w( "#textInloggen" ).onClick(logoutAndRedirect);
function logoutAndRedirect(event) {
Promise.all( wixLocation.to( ‘/home’ ), wixUsers.logout()
.then( () => {
$w( "#textInloggen" ).label = "Inloggen" ;
$w( "#textMijnAccount" ).collapse()
}))}}}
else {
wixWindow.openLightbox( “inloggen” )
$w( "#boxInloggen" ).collapse()
. **catch** ( (err) => {
console.log(err);
} );
}
}
export function textMijnAccount_onClick() {
wixLocation.to(/account/account
);
}