fix26: полный прод-фикс auth/jwt, import-export peer и frontend flow
This commit is contained in:
@@ -24,6 +24,10 @@ router.beforeEach(async (to, from, next) => {
|
||||
const adminStore = useAdminStoreHook();
|
||||
const hasRoles = adminStore.roles && adminStore.roles.length > 0;
|
||||
if (hasRoles) {
|
||||
if (adminStore.forcePasswordChange && to.path !== "/admin/change-password") {
|
||||
next({ path: "/admin/change-password", query: { redirect: to.fullPath } });
|
||||
return;
|
||||
}
|
||||
// Если маршрут не найден, перейти на 404
|
||||
if (to.matched.length === 0) {
|
||||
from.name ? next({ name: from.name }) : next("/404");
|
||||
@@ -32,11 +36,15 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const { roles } = await adminStore.getAdminInfo();
|
||||
const { roles, forcePasswordChange } = await adminStore.getAdminInfo();
|
||||
const accessRoutes = permissionStore.generateRoutes(roles);
|
||||
accessRoutes.forEach((route) => {
|
||||
router.addRoute(route);
|
||||
});
|
||||
if (forcePasswordChange && to.path !== "/admin/change-password") {
|
||||
next({ path: "/admin/change-password", query: { redirect: to.fullPath }, replace: true });
|
||||
return;
|
||||
}
|
||||
next({ ...to, replace: true });
|
||||
} catch (error) {
|
||||
// Удалить token и перейти на страницу входа
|
||||
@@ -61,4 +69,3 @@ router.afterEach(() => {
|
||||
NProgress.done();
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user