Allow authenticated members to bypass coming-soon page
Add JWT-verified session check to coming-soon middleware so logged-in members can access the full site. Add member login link and modal to the coming-soon page so members can sign in before launch.
This commit is contained in:
parent
6f297cf137
commit
79d3ba0f78
2 changed files with 30 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
export default defineNuxtRouteMiddleware((to, from) => {
|
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
const config = useRuntimeConfig();
|
const config = useRuntimeConfig();
|
||||||
const isComingSoonMode =
|
const isComingSoonMode =
|
||||||
config.public.comingSoon === "true" || config.public.comingSoon === true;
|
config.public.comingSoon === "true" || config.public.comingSoon === true;
|
||||||
|
|
@ -13,6 +13,25 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow authenticated users to bypass coming-soon
|
||||||
|
const authToken = useCookie("auth-token");
|
||||||
|
if (authToken.value) {
|
||||||
|
// On the server, verify the JWT is actually valid
|
||||||
|
if (import.meta.server) {
|
||||||
|
try {
|
||||||
|
const { jwtSecret } = useRuntimeConfig();
|
||||||
|
const jwt = await import("jsonwebtoken").then((m) => m.default);
|
||||||
|
jwt.verify(authToken.value, jwtSecret);
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
// Invalid/expired token — fall through to coming-soon redirect
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Client-side: trust the cookie (SSR already validated on initial load)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Redirect all other routes to coming-soon
|
// Redirect all other routes to coming-soon
|
||||||
return navigateTo("/coming-soon");
|
return navigateTo("/coming-soon");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="min-h-screen w-full flex items-center justify-center">
|
<div class="min-h-screen w-full flex flex-col items-center justify-center">
|
||||||
<a href="https://babyghosts.fund/ghost-guild" class="text-center">
|
<a href="https://babyghosts.fund/ghost-guild" class="text-center">
|
||||||
<h1 class="text-5xl md:text-6xl font-bold mb-4">Ghost Guild</h1>
|
<h1 class="text-5xl md:text-6xl font-bold mb-4">Ghost Guild</h1>
|
||||||
<p class="text-xl md:text-2xl">Coming Soon</p>
|
<p class="text-xl md:text-2xl">Coming Soon</p>
|
||||||
</a>
|
</a>
|
||||||
|
<button
|
||||||
|
class="mt-12 text-sm text-guild-500 hover:text-guild-300 transition-colors"
|
||||||
|
@click="openLoginModal"
|
||||||
|
>
|
||||||
|
Member login
|
||||||
|
</button>
|
||||||
|
<LoginModal />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -11,4 +18,6 @@
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "coming-soon",
|
layout: "coming-soon",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { openLoginModal } = useLoginModal();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue