mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-13 16:01:06 +03:30
mixin role and config url
This commit is contained in:
Vendored
+9
-2
@@ -8,7 +8,7 @@
|
||||
|
||||
// Lib imports
|
||||
import Vue from 'vue'
|
||||
import VueAnalytics from 'vue-analytics'
|
||||
// import VueAnalytics from 'vue-analytics'
|
||||
import Router from 'vue-router'
|
||||
import Meta from 'vue-meta'
|
||||
import { TokenService } from '@/services'
|
||||
@@ -52,10 +52,12 @@ const router = new Router({
|
||||
|
||||
Vue.use(Meta)
|
||||
|
||||
|
||||
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();
|
||||
const roles = to.matched.some(record => record.meta.roles);
|
||||
if (!isPublic && !loggedIn) {
|
||||
return next({
|
||||
path:'/login',
|
||||
@@ -64,10 +66,15 @@ router.beforeEach((to, from, next) => {
|
||||
}
|
||||
|
||||
// Do not allow user to visit login page or register page if they are logged in
|
||||
if (loggedIn && onlyWhenLoggedOut) {
|
||||
if (loggedIn && onlyWhenLoggedOut && policy) {
|
||||
return next('/')
|
||||
}
|
||||
|
||||
// Do not allow user to visit Pages then not access roles
|
||||
// if (roles && !$hasRole(roles)) {
|
||||
// return next('/')
|
||||
// }
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -6,8 +6,8 @@
|
||||
export default [
|
||||
{
|
||||
path: '/dashboard',
|
||||
// Relative to /src/views
|
||||
view: 'Dashboard'
|
||||
name: 'Dashboard',
|
||||
view: 'Dashboard',
|
||||
},
|
||||
{
|
||||
path: '/my-info',
|
||||
@@ -22,7 +22,7 @@ export default [
|
||||
{
|
||||
path: '/manage-users',
|
||||
name: 'Manage Users',
|
||||
view: 'ManageUsers'
|
||||
view: 'ManageUsers',
|
||||
},
|
||||
{
|
||||
path: '/test-creator',
|
||||
@@ -74,7 +74,7 @@ export default [
|
||||
meta: {
|
||||
public: true, // Allow access to even if not logged in
|
||||
onlyWhenLoggedOut: true
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/test-creator',
|
||||
|
||||
Reference in New Issue
Block a user