add new landing page firstlogin close #18

This commit is contained in:
Adrian Zürcher
2025-12-10 14:05:37 +01:00
parent 714ca0219a
commit 6be85e86af
14 changed files with 119 additions and 20 deletions

View File

@@ -17,6 +17,8 @@ import { useUserStore } from 'src/vueLib/login/userStore';
* with the Router instance.
*/
export let routerInstance: ReturnType<typeof createRouter>;
export default defineRouter(function (/* { store, ssrContext } */) {
const createHistory = process.env.SERVER
? createMemoryHistory
@@ -34,10 +36,16 @@ export default defineRouter(function (/* { store, ssrContext } */) {
history: createHistory(process.env.VUE_ROUTER_BASE),
});
routerInstance = Router;
Router.beforeEach((to, from, next) => {
const userStore = useUserStore();
const isLoggedIn = userStore.isAuthenticated;
if (to.meta.requiresAuth && !isLoggedIn) {
if (!userStore.$state.firstLogin && to.path === '/firstlogin') {
next('/login');
} else if (userStore.$state.firstLogin && to.path !== '/firstlogin') {
next('/firstlogin');
} else if (to.meta.requiresAuth && !isLoggedIn) {
next('/login');
} else if (
to.meta.requiresAdmin &&