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:
Jennie Robinson Faber 2026-03-01 19:51:50 +00:00
parent 6f297cf137
commit 79d3ba0f78
2 changed files with 30 additions and 2 deletions

View file

@ -1,4 +1,4 @@
export default defineNuxtRouteMiddleware((to, from) => {
export default defineNuxtRouteMiddleware(async (to, from) => {
const config = useRuntimeConfig();
const isComingSoonMode =
config.public.comingSoon === "true" || config.public.comingSoon === true;
@ -13,6 +13,25 @@ export default defineNuxtRouteMiddleware((to, from) => {
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
return navigateTo("/coming-soon");
});