Fix : add login page
This commit is contained in:
@@ -3,24 +3,6 @@ import { useAuthStore } from "#imports";
|
||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
const authStore = useAuthStore();
|
||||
const config = useRuntimeConfig();
|
||||
if (to.path == "/login") {
|
||||
const code = to.query.code;
|
||||
if (!code) {
|
||||
return navigateTo(config.public.discordLoginEndpoint, { external: true });
|
||||
}
|
||||
|
||||
if (!Array.isArray(code)) {
|
||||
try {
|
||||
await authStore.whoami();
|
||||
return navigateTo("/lobby");
|
||||
} catch {
|
||||
return navigateTo("/login");
|
||||
}
|
||||
} else {
|
||||
return navigateTo("/login");
|
||||
}
|
||||
}
|
||||
|
||||
// if (to.path == '/') {
|
||||
// const code = to.query.code
|
||||
// if (code) {
|
||||
@@ -51,14 +33,17 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
// return navigateTo('/login')
|
||||
// }
|
||||
// }
|
||||
console.log(to.path)
|
||||
console.log(to.path);
|
||||
if (to.path.startsWith("/game")) {
|
||||
console.log(to.query.id)
|
||||
console.log(to.query.id);
|
||||
// if (Array.isArray(to.query.id)) {
|
||||
// return navigateTo("/lobby");
|
||||
// }
|
||||
return;
|
||||
}
|
||||
if (to.path == "/login") {
|
||||
return;
|
||||
}
|
||||
if (to.path == "/lobby") {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
const route = useRoute();
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
const code = route.query.code;
|
||||
|
||||
if (!code) {
|
||||
navigateTo(config.public.discordLoginEndpoint, { external: true });
|
||||
} else {
|
||||
navigateTo("/login");
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user