Normaly after logOut → your site restarts with your setted-up staarting page automatically.
Didn’t you already setted-up your HOMEPAGE as starting page?
When you do a LOGOUT, out of my knowledge you stay at the same page (AS LONG AS THE PAGE IS NOT A PW-PROTECTED ONE, OR HAS OTHER RESTRICTIONS REGARDING ACCESSIBILITY).
Example:
a) loging out on a PW-secured page → will leave the current page
b) loging-out on an ordinary page ----> you will stay at the current page (no navigation to another page)
But what is 100% sure is, that after logout-process the page REALOADS, that means your code can not work.
You could use the Wix-Storage for your puspose to save a command for navigation inside of wix-storage and then when your page (MASTER-PAGE) loads you check for the saved command inside of your STORAGE first and see if a command has been left to do a navigation.
First of all —> your onLogin()-function must be inside of the $w.onReady()-event !!!
Second —> this do not exist → wixLocationFrontend.to
You should have generated something like…
import {authentication} from 'wix-members-frontend';
import {local} from 'wix-storage-frontend';
$w.onReady(()=> {console.log('Page is ready...');
//...your check-function first.....
checkLoginState();
authentication.onLogin(async(member)=> {console.log('MEMBER: ', member);
const loggedInMember = await member.getMember(); console.log('Logged-In-MEMBER: ', loggedInMember);
const memberId = loggedInMember._id; console.log('Member-ID: ', memberId);
console.log(`Member ${memberId} logged in:`, loggedInMember);
//start REDIRECTION....
wixLocation.to("/account/businfo");
});
authentication.onLogout(()=> {console.log('Member logged-out');});
$w('#logInButton').onClick(()=>{local.setItem("login", "true");
let email = ????????????????????????;
let password = ?????????????????????;
logIn(email, password);
});
$w('#logOutButton').onClick(()=>{local.setItem("login", "false"); authentication.logout();});
//After clicking the Log-Out-Button --> the page should RESTART!
//Now you need to implement a CHECK-FUNCTION, which will check for the saved value inside of the STORAGE!
//EXPAND YOUR CODE, to be able to CHECK for STORAGE-VALUE on LOAD of the page, if "login", has been set to TRUE or FALSE.........
});
function checkLoginState() {
return local.getItem("login");
}
function logIn(email, password) {
authentication.login(email, password)
.then(()=> {console.log('Member is logged in');})
.catch((err)=> {console.error(err);});
}