mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-11 15:34:50 +00:00
- Add Administration sidebar section (super-admin only) with Companies, Users, and Global Settings pages - Add super-admin middleware, controllers, and API routes under /api/v1/super-admin/ - Allow super-admins to manage all companies and users across tenants - Add user impersonation with short-lived tokens, audit logging, and UI banner - Move system-level settings (Mail, PDF, Backup, Update, File Disk) from per-company to Administration > Global Settings - Convert save_pdf_to_disk from CompanySetting to global Setting - Add per-company mail configuration overrides (optional, falls back to global) - Add CompanyMailConfigService to apply company mail config before sending emails
42 lines
1.1 KiB
JavaScript
Vendored
42 lines
1.1 KiB
JavaScript
Vendored
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useUserStore } from '@/scripts/admin/stores/user'
|
|
import { useGlobalStore } from '@/scripts/admin/stores/global'
|
|
|
|
//admin routes
|
|
import AdminRoutes from '@/scripts/admin/admin-router'
|
|
// Customers routes
|
|
import CustomerRoutes from '@/scripts/customer/customer-router'
|
|
//Payment Routes
|
|
|
|
let routes = []
|
|
routes = routes.concat(AdminRoutes, CustomerRoutes)
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
linkActiveClass: 'active',
|
|
routes,
|
|
})
|
|
|
|
router.beforeEach((to) => {
|
|
const userStore = useUserStore()
|
|
const globalStore = useGlobalStore()
|
|
let ability = to.meta.ability
|
|
const { isAppLoaded } = globalStore
|
|
|
|
if (ability && isAppLoaded && to.meta.requiresAuth) {
|
|
if (!userStore.hasAbilities(ability)) {
|
|
return { name: 'account.settings' }
|
|
}
|
|
} else if (to.meta.isSuperAdmin && isAppLoaded) {
|
|
if (!userStore.currentUser.is_super_admin) {
|
|
return { name: 'dashboard' }
|
|
}
|
|
} else if (to.meta.isOwner && isAppLoaded) {
|
|
if (!userStore.currentUser.is_owner) {
|
|
return { name: 'dashboard' }
|
|
}
|
|
}
|
|
})
|
|
|
|
export default router
|