This commit is contained in:
xCyanGrizzly
2026-02-18 14:26:36 +01:00
commit 3a5726e82b
167 changed files with 104081 additions and 0 deletions

25
src/lib/auth.config.ts Normal file
View File

@@ -0,0 +1,25 @@
import type { NextAuthConfig } from "next-auth";
export default {
pages: {
signIn: "/login",
error: "/login",
},
callbacks: {
authorized({ auth, request: { nextUrl } }) {
const isLoggedIn = !!auth?.user;
const isAuthPage =
nextUrl.pathname.startsWith("/login") || nextUrl.pathname.startsWith("/register");
const isApiAuth = nextUrl.pathname.startsWith("/api/auth");
const isHealth = nextUrl.pathname.startsWith("/api/health");
if (isHealth || isApiAuth) return true;
if (isAuthPage) {
if (isLoggedIn) return Response.redirect(new URL("/dashboard", nextUrl));
return true;
}
return isLoggedIn;
},
},
providers: [],
} satisfies NextAuthConfig;