diff --git a/app/api/auth/[...nextauth]/route.js b/app/api/auth/[...nextauth]/route.js index aaeb3c0..1d02ad8 100644 --- a/app/api/auth/[...nextauth]/route.js +++ b/app/api/auth/[...nextauth]/route.js @@ -3,6 +3,7 @@ import CredentialsProvider from "next-auth/providers/credentials"; import { validateCredentials } from "@/actions/auth"; export const authOptions = { + debug: process.env.NODE_ENV === "development", providers: [ CredentialsProvider({ id: "credentials", @@ -12,21 +13,19 @@ export const authOptions = { password: { label: "Password", type: "password" }, }, async authorize(credentials) { - try { - if (!credentials?.username || !credentials?.password) { - return null; - } - - const user = await validateCredentials( - credentials.username, - credentials.password - ); - - return user; - } catch (error) { - console.error("Auth error:", error); - return null; - } + if (!credentials?.username || !credentials?.password) return null; + const user = await validateCredentials( + credentials.username, + credentials.password + ); + return user + ? { + id: user.id, + username: user.username, + role: user.role, + teamId: user.teamId, + } + : null; }, }), ], @@ -51,12 +50,8 @@ export const authOptions = { return session; }, }, - pages: { - signIn: "/login", - }, - session: { - strategy: "jwt", - }, + pages: { signIn: "/login" }, + session: { strategy: "jwt", maxAge: 30 * 24 * 60 * 60 }, secret: process.env.NEXTAUTH_SECRET, }; diff --git a/app/layout.js b/app/layout.js index 7eecd5b..66d1a68 100644 --- a/app/layout.js +++ b/app/layout.js @@ -4,7 +4,7 @@ import { NextAuthProvider } from "./providers"; export default function RootLayout({ children }) { return ( -
+