front > login : fix redirection when user is already logged in
This commit is contained in:
parent
e30a80c4ff
commit
619e124fc4
3 changed files with 25 additions and 14 deletions
|
|
@ -17,15 +17,13 @@ router.beforeEach(async (to, from, next) => {
|
|||
try {
|
||||
const res = await api.fetchData(to.path);
|
||||
|
||||
if (!res.user && to.path === '/login' && from.path === '/login') {
|
||||
next();
|
||||
} else if (res.user && to.path === '/login') {
|
||||
next('/');
|
||||
} else {
|
||||
pageStore.page = res.page;
|
||||
userStore.user = res.user;
|
||||
next();
|
||||
if (to.path === '/login' && res.user) {
|
||||
location.href = '/';
|
||||
}
|
||||
|
||||
pageStore.page = res.page;
|
||||
userStore.user = res.user;
|
||||
next();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
next(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue