mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
Init
This commit is contained in:
25
src/lib/auth.config.ts
Normal file
25
src/lib/auth.config.ts
Normal 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;
|
||||
Reference in New Issue
Block a user