refactor: constanten redirect vervangen door enum
This commit is contained in:
parent
4600e5dd9e
commit
064897acd5
3 changed files with 22 additions and 6 deletions
|
@ -14,6 +14,7 @@ import UserHomePage from "@/views/homepage/UserHomePage.vue";
|
|||
import SingleTheme from "@/views/SingleTheme.vue";
|
||||
import LearningObjectView from "@/views/learning-paths/learning-object/LearningObjectView.vue";
|
||||
import authService from "@/services/auth/auth-service";
|
||||
import {allowRedirect, Redirect} from "@/utils/redirect.ts";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
|
@ -144,10 +145,10 @@ router.beforeEach(async (to, _from, next) => {
|
|||
if (to.meta.requiresAuth) {
|
||||
if (!authService.isLoggedIn.value && !(await authService.loadUser())) {
|
||||
const path = to.fullPath;
|
||||
if (path !== "/") {
|
||||
localStorage.setItem("redirectAfterLogin", path);
|
||||
if (allowRedirect(path)) {
|
||||
localStorage.setItem(Redirect.AFTER_LOGIN_KEY, path);
|
||||
}
|
||||
next("/login");
|
||||
next(Redirect.LOGIN);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue