Skip to content

Commit

Permalink
fix(reload_persist): Make return to login page on reload to prevent r…
Browse files Browse the repository at this point in the history
…ole rights issues (#1415)
  • Loading branch information
NyraSama authored Apr 30, 2024
1 parent 37f9396 commit 113656a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion yaki_admin/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ const router = createRouter({
// BEGIN: be15d9bcejpp
router.beforeEach(async (to) => {
// redirect to login page if not logged in and trying to access a restricted page
const publicPages = ["/", "/registerConfirm"];
const publicPages = ["/"];
const authRequired = !publicPages.includes(to.path);
const auth = useAuthStore();

// Logout on reload
const role = useRoleStore();
if (auth.user && role.captainsId.length === 0 && role.customersIdWhereIgotRights.length === 0) {
auth.logout();
}

if (authRequired && !auth.user) {
auth.returnedUrl = to.fullPath;
return "/";
Expand Down
5 changes: 3 additions & 2 deletions yaki_admin/src/ui/views/ProfileView.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<script setup lang="ts">
import PageContentHeader from "@/ui/components/PageContentHeader.vue";
import PageContentLayout from "@/ui/layouts/PageContentLayout.vue";
import router from "@/router/router";
import buttonSecondary from "@/ui/components/buttons/ButtonSecondary.vue";
import LanguageSwitch from "../components/LanguageSwitch.vue";
import { useAuthStore } from "@/stores/authStore";
const logOff = () => {
router.push("/");
const authStore = useAuthStore();
authStore.logout();
};
</script>

Expand Down

0 comments on commit 113656a

Please sign in to comment.