add new landing page firstlogin close #18
This commit is contained in:
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user