Same model as DriverVault, with organizations above workspaces: - users get a role (user, admin, superadmin) and at most one organization; existing instance admins become superadmins - rights cascade: superadmins own everything, org admins own their organization's workspaces, others get their workspace role (owner > admin > member > guest) while they stay in the org - nobody grants a role above their own, acts on someone ranked above them, or changes their own role; rules live in internal/access as pure, tested functions - self-service organizations: an org-less user creates one and becomes its admin; the last admin can delete it and is demoted - endpoints for users, orgs, workspaces and members; token cache is dropped when a user's rights change - admin panel: Users and Organizations pages scoped to the caller - web app: organization page, workspace list, workspace settings with member management (EN/PL) - fix: organization name missing after login/refresh, and stale tokens redirecting public pages to sign-in Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.7 KiB
TypeScript
30 lines
1.7 KiB
TypeScript
import { createApp } from "vue";
|
|
import { createRouter, createWebHistory } from "vue-router";
|
|
import App from "./App.vue";
|
|
import { currentUser, isSuperadmin, restoreSession } from "./session";
|
|
import "./style.css";
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory("/admin/"),
|
|
routes: [
|
|
{ path: "/login", name: "login", component: () => import("./views/LoginView.vue"), meta: { public: true } },
|
|
{ path: "/", name: "overview", component: () => import("./views/OverviewView.vue") },
|
|
{ path: "/users", name: "users", component: () => import("./views/UsersView.vue") },
|
|
{ path: "/organizations", name: "organizations", component: () => import("./views/OrganizationsView.vue") },
|
|
{ path: "/authentication", name: "authentication", component: () => import("./views/PlaceholderView.vue"), meta: { title: "Authentication", superadmin: true } },
|
|
{ path: "/storage", name: "storage", component: () => import("./views/PlaceholderView.vue"), meta: { title: "Storage", superadmin: true } },
|
|
{ path: "/email", name: "email", component: () => import("./views/PlaceholderView.vue"), meta: { title: "Email", superadmin: true } },
|
|
{ path: "/maintenance", name: "maintenance", component: () => import("./views/PlaceholderView.vue"), meta: { title: "Maintenance", superadmin: true } },
|
|
],
|
|
});
|
|
|
|
router.beforeEach(async (to) => {
|
|
await restoreSession();
|
|
if (!to.meta.public && !currentUser.value) return { name: "login", query: { redirect: to.fullPath } };
|
|
if (to.name === "login" && currentUser.value) return { name: "overview" };
|
|
// Instance-wide settings are for superadmins; org admins manage their org only.
|
|
if (to.meta.superadmin && !isSuperadmin.value) return { name: "overview" };
|
|
});
|
|
|
|
createApp(App).use(router).mount("#app");
|