Skip to content

Commit 113656a

Browse files
authored
fix(reload_persist): Make return to login page on reload to prevent role rights issues (#1415)
1 parent 37f9396 commit 113656a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

yaki_admin/src/router/router.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,16 @@ const router = createRouter({
7474
// BEGIN: be15d9bcejpp
7575
router.beforeEach(async (to) => {
7676
// redirect to login page if not logged in and trying to access a restricted page
77-
const publicPages = ["/", "/registerConfirm"];
77+
const publicPages = ["/"];
7878
const authRequired = !publicPages.includes(to.path);
7979
const auth = useAuthStore();
8080

81+
// Logout on reload
82+
const role = useRoleStore();
83+
if (auth.user && role.captainsId.length === 0 && role.customersIdWhereIgotRights.length === 0) {
84+
auth.logout();
85+
}
86+
8187
if (authRequired && !auth.user) {
8288
auth.returnedUrl = to.fullPath;
8389
return "/";

yaki_admin/src/ui/views/ProfileView.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<script setup lang="ts">
22
import PageContentHeader from "@/ui/components/PageContentHeader.vue";
33
import PageContentLayout from "@/ui/layouts/PageContentLayout.vue";
4-
import router from "@/router/router";
54
import buttonSecondary from "@/ui/components/buttons/ButtonSecondary.vue";
65
import LanguageSwitch from "../components/LanguageSwitch.vue";
6+
import { useAuthStore } from "@/stores/authStore";
77
88
const logOff = () => {
9-
router.push("/");
9+
const authStore = useAuthStore();
10+
authStore.logout();
1011
};
1112
</script>
1213

0 commit comments

Comments
 (0)