mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 03:10:11 +08:00
feat: separate Login and Register Page
This commit is contained in:
1 parent
7a9206fb47
commit
30aeacaf06
6 files changed
+159
-114
No files matched your search
+11
-4
@@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import GamePage from './views/GamePage.vue'
|
||||
import AuthPage from './views/AuthPage.vue'
|
||||
import LoginPage from './views/LoginPage.vue'
|
||||
import RegisterPage from './views/RegisterPage.vue'
|
||||
import ChooseUsernamePage from './views/ChooseUsernamePage.vue'
|
||||
import { isLoggedIn } from './utils/auth'
|
||||
|
||||
@@ -11,8 +12,14 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'auth',
|
||||
component: AuthPage,
|
||||
name: 'login',
|
||||
component: LoginPage,
|
||||
meta: { requiresGuest: true },
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'register',
|
||||
component: RegisterPage,
|
||||
meta: { requiresGuest: true },
|
||||
},
|
||||
{
|
||||
@@ -41,7 +48,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
// Check if the user isn't authenticated
|
||||
// Redirect to the login page
|
||||
next({
|
||||
name: 'auth',
|
||||
name: 'register',
|
||||
query: { redirect: to.fullPath }, // Optionally pass a redirect parameter
|
||||
})
|
||||
} else if (to.meta.requiresGuest && loggedIn) {
|
||||
|
||||
Reference in new issue
Block a user