Files
timmal/app/middleware/auth.global.ts
Lucien Cartier-Tilet 40ae2145cc
All checks were successful
ci / ci (push) Successful in 16m22s
feat: authentication with OAuth
2025-12-12 03:08:52 +01:00

15 lines
388 B
TypeScript

export default defineNuxtRouteMiddleware((to, _from) => {
const { isAuthenticated } = useAuth();
const allowedUnauthenticatedPaths: string[] = ['/', '/login'];
if (allowedUnauthenticatedPaths.find((p) => p === to.path)) {
return;
}
if (!isAuthenticated.value) {
return navigateTo({
path: '/login',
query: { redirect: to.fullPath },
});
}
return;
});