mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-14 02:31:06 +03:30
route middleware And Login
This commit is contained in:
Vendored
+19
-19
@@ -20,7 +20,7 @@ function route (options) {
|
||||
let path = options.path;
|
||||
let view = options.view;
|
||||
let name = options.name;
|
||||
let meta = (path.meta) ? path.meta : '';
|
||||
let meta = (options.meta) ? options.meta : '';
|
||||
return {
|
||||
name: name || view,
|
||||
path,
|
||||
@@ -56,17 +56,17 @@ router.beforeEach((to, from, next) => {
|
||||
const isPublic = to.matched.some(record => record.meta.public);
|
||||
const onlyWhenLoggedOut = to.matched.some(record => record.meta.onlyWhenLoggedOut);
|
||||
const loggedIn = !!TokenService.getToken();
|
||||
// if (!isPublic && !loggedIn) {
|
||||
// return next({
|
||||
// path:'/login',
|
||||
// query: {redirect: to.fullPath} // Store the full path to redirect the user to after login
|
||||
// });
|
||||
// }
|
||||
if (!isPublic && !loggedIn) {
|
||||
return next({
|
||||
path:'/login',
|
||||
query: {redirect: to.fullPath} // Store the full path to redirect the user to after login
|
||||
});
|
||||
}
|
||||
|
||||
// Do not allow user to visit login page or register page if they are logged in
|
||||
// if (loggedIn && onlyWhenLoggedOut) {
|
||||
// return next('/')
|
||||
// }
|
||||
if (loggedIn && onlyWhenLoggedOut) {
|
||||
return next('/')
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
@@ -74,14 +74,14 @@ router.beforeEach((to, from, next) => {
|
||||
// Bootstrap Analytics
|
||||
// Set in .env
|
||||
// https://github.com/MatteoGabriele/vue-analytics
|
||||
if (process.env.GOOGLE_ANALYTICS) {
|
||||
Vue.use(VueAnalytics, {
|
||||
id: process.env.GOOGLE_ANALYTICS,
|
||||
router,
|
||||
autoTracking: {
|
||||
page: process.env.NODE_ENV !== 'development'
|
||||
}
|
||||
})
|
||||
}
|
||||
// if (process.env.GOOGLE_ANALYTICS) {
|
||||
// Vue.use(VueAnalytics, {
|
||||
// id: process.env.GOOGLE_ANALYTICS,
|
||||
// router,
|
||||
// autoTracking: {
|
||||
// page: process.env.NODE_ENV !== 'development'
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user