로그인 화면
This commit is contained in:
1 parent
6adcb5b43d
commit
f551671394
13 files changed
+152
-30
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import VueRouter from "vue-router";
|
||||
import routes from "./routes";
|
||||
import { isAuthenticated, safeDestination } from '@/auth';
|
||||
|
||||
// configure router
|
||||
const router = new VueRouter({
|
||||
@@ -14,4 +15,12 @@ const router = new VueRouter({
|
||||
}
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.matched.some(record => record.meta.requiresAuth) && !isAuthenticated()) {
|
||||
next({ path: '/login', query: { redirect: to.fullPath }, replace: true });
|
||||
} else if (to.name === 'login' && isAuthenticated()) {
|
||||
next({ path: safeDestination(to.query.redirect), replace: true });
|
||||
} else next();
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in new issue
Block a user