Add permissions
This commit is contained in:
@@ -34,13 +34,14 @@ const routerInstance = createRouter({
|
||||
|
||||
export default route(function (/* { store, ssrContext } */) {
|
||||
|
||||
routerInstance.beforeEach(async (to) => {
|
||||
routerInstance.beforeEach(async (to, from) => {
|
||||
// clear alert on route change
|
||||
//const alertStore = useAlertStore();
|
||||
//alertStore.clear();
|
||||
|
||||
// redirect to login page if not logged in and trying to access a restricted page
|
||||
const publicPages = ['/login'];
|
||||
const loginPage = '/login';
|
||||
const publicPages = [loginPage];
|
||||
const authRequired = !publicPages.includes(to.path);
|
||||
const authStore = useAuthStore();
|
||||
|
||||
@@ -49,8 +50,12 @@ export default route(function (/* { store, ssrContext } */) {
|
||||
return '/login';
|
||||
}
|
||||
|
||||
if (authStore.token && to.path === loginPage) {
|
||||
return from.path == '/' ? '/' : false;
|
||||
}
|
||||
|
||||
// redirect to domain setting page if no domain exist
|
||||
const domainPages = [...publicPages, '/domain', '/userDomain', '/user'];
|
||||
const domainPages = [...publicPages, '/domain', '/userDomain', '/user', '/role'];
|
||||
if (!authStore.hasDomain && !domainPages.includes(to.path)) {
|
||||
Dialog.create({
|
||||
title: '注意',
|
||||
|
||||
Reference in New Issue
Block a user