docs: Update architecture for supabase
test: Add tests for auth workflow
This commit is contained in:
14
app/utils/auth.ts
Normal file
14
app/utils/auth.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user