中文:收口权限与中心/立项配置改造
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
|
||||
import { useAuthStore } from "../store/auth";
|
||||
import { useStudyStore } from "../store/study";
|
||||
import { getProjectRole, isSystemAdmin } from "../utils/roles";
|
||||
import Layout from "../components/Layout.vue";
|
||||
import Login from "../views/Login.vue";
|
||||
import Register from "../views/Register.vue";
|
||||
@@ -477,7 +478,7 @@ router.beforeEach(async (to, _from, next) => {
|
||||
}
|
||||
}
|
||||
token = getToken();
|
||||
const isAdmin = auth.user?.role === "ADMIN";
|
||||
const isAdmin = isSystemAdmin(auth.user);
|
||||
if (token && !studyStore.currentStudy) {
|
||||
if (isAdmin) {
|
||||
await studyStore.ensureDefaultActiveStudy();
|
||||
@@ -510,14 +511,13 @@ router.beforeEach(async (to, _from, next) => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (to.meta.requiresAdmin && auth.user?.role !== "ADMIN") {
|
||||
if (to.meta.requiresAdmin && !isAdmin) {
|
||||
next({ path: "/workbench" });
|
||||
return;
|
||||
}
|
||||
if (to.name === "AuditLogs") {
|
||||
const role = auth.user?.role;
|
||||
const studyRole = studyStore.currentStudyRole;
|
||||
if (!(role === "ADMIN" || role === "PM" || studyRole === "PM")) {
|
||||
const projectRole = getProjectRole(studyStore.currentStudy, studyStore.currentStudyRole);
|
||||
if (!(isAdmin || projectRole === "PM")) {
|
||||
next({ path: "/project/overview" });
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user