fix: make workspace navigation atomic and return home on account switch

This commit is contained in:
SantaSpeen committed 2026-10-25 21:19:10 +03:00
1 parent c02bf755f2
commit 55f2474660
21 files changed
+709 -61

No files matched your search

+11
View File
@@ -14,6 +14,7 @@ import { useAuthStore } from "@/stores/auth";
import { baseURL, name } from "@/utils/constants";
import i18n from "@/i18n";
import { validateLogin } from "@/utils/auth";
import { installResourceNavigation } from "@/utils/resource-navigation";
const titles = {
CraftEditor: "addons.title",
@@ -203,6 +204,9 @@ router.beforeResolve(async (to, from) => {
};
}
if (authStore.accountChanged && to.path !== "/files/")
return { path: "/files/" };
if (to.matched.some((record) => record.meta.requiresAdmin)) {
if (authStore.user === null || !authStore.user.perm.admin) {
return { path: "/403" };
@@ -213,4 +217,11 @@ router.beforeResolve(async (to, from) => {
return;
});
installResourceNavigation(router);
router.afterEach((to, _from, failure) => {
if (!failure && to.name === "Files" && to.path === "/files/")
useAuthStore().accountChanged = false;
});
export { router, router as default };