Creating a CRM Super Admin
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import type { UserRole } from '@mento/shared';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { usePlatformAuthStore } from '@/stores/platform-auth';
|
||||
|
||||
export const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
@@ -29,6 +30,34 @@ export const router = createRouter({
|
||||
component: () => import('@/views/PortalView.vue'),
|
||||
meta: { public: true },
|
||||
},
|
||||
{
|
||||
path: '/adm',
|
||||
name: 'adm-login',
|
||||
component: () => import('@/views/adm/AdmLoginView.vue'),
|
||||
meta: { public: true, platformPublic: true },
|
||||
},
|
||||
{
|
||||
path: '/adm',
|
||||
component: () => import('@/layouts/AdmLayout.vue'),
|
||||
meta: { public: true, platform: true },
|
||||
children: [
|
||||
{
|
||||
path: 'dashboard',
|
||||
name: 'adm-dashboard',
|
||||
component: () => import('@/views/adm/AdmDashboardView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'organizations',
|
||||
name: 'adm-organizations',
|
||||
component: () => import('@/views/adm/AdmOrganizationsView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'users',
|
||||
name: 'adm-users',
|
||||
component: () => import('@/views/adm/AdmUsersView.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: () => import('@/layouts/AppLayout.vue'),
|
||||
@@ -291,6 +320,16 @@ export const router = createRouter({
|
||||
});
|
||||
|
||||
router.beforeEach((to) => {
|
||||
if (to.path === '/adm' || to.path.startsWith('/adm/')) {
|
||||
const platform = usePlatformAuthStore();
|
||||
if (to.meta.platformPublic) {
|
||||
if (platform.isAuthenticated) return { name: 'adm-dashboard' };
|
||||
return true;
|
||||
}
|
||||
if (!platform.isAuthenticated) return { name: 'adm-login' };
|
||||
return true;
|
||||
}
|
||||
|
||||
const auth = useAuthStore();
|
||||
if (!to.meta.public && !auth.isAuthenticated) {
|
||||
return { name: 'login', query: { redirect: to.fullPath } };
|
||||
|
||||
Reference in New Issue
Block a user