Add permissions

This commit is contained in:
xue jiahao
2024-12-24 22:17:18 +08:00
parent 5ebfd22652
commit a92873b971
11 changed files with 173 additions and 103 deletions

View File

@@ -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: '注意',