15 lines
447 B
TypeScript
15 lines
447 B
TypeScript
export const PUBLIC_ROUTES = ['/', '/login', '/signup', '/auth/callback'] as const
|
|
|
|
/**
|
|
* Pure auth decision logic — no Nuxt/Supabase dependencies.
|
|
* Returns the path to redirect to, or null if no redirect is needed.
|
|
*/
|
|
export function checkAuthRedirect(
|
|
userValue: { id: string } | null,
|
|
path: string,
|
|
): string | null {
|
|
if ((PUBLIC_ROUTES as readonly string[]).includes(path)) return null
|
|
if (!userValue) return '/'
|
|
return null
|
|
}
|