feat: separate Login and Register Page

This commit is contained in:
Lin, Hung-Shin committed 2023-10-13 16:13:25 +08:00
1 parent 7a9206fb47
commit 30aeacaf06
6 files changed
+159 -114

No files matched your search

+11 -4
View File
@@ -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) {