chore: clean up code by removing trailing whitespace and ensuring consistent formatting across various files = prettier
This commit is contained in:
@@ -6,4 +6,3 @@ import type { Account } from "./types";
|
||||
export function getAccountBalance(account: Account): number {
|
||||
return (account.initialBalance || 0) + account.balance;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,10 @@ import { NextResponse } from "next/server";
|
||||
*/
|
||||
export async function requireAuth(): Promise<NextResponse | null> {
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
|
||||
if (!session) {
|
||||
return NextResponse.json(
|
||||
{ error: "Non authentifié" },
|
||||
{ status: 401 }
|
||||
);
|
||||
return NextResponse.json({ error: "Non authentifié" }, { status: 401 });
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
17
lib/auth.ts
17
lib/auth.ts
@@ -3,16 +3,22 @@ import CredentialsProvider from "next-auth/providers/credentials";
|
||||
import { authService } from "@/services/auth.service";
|
||||
|
||||
// Get secret with fallback for development
|
||||
const secret = process.env.NEXTAUTH_SECRET || "dev-secret-key-change-in-production";
|
||||
const secret =
|
||||
process.env.NEXTAUTH_SECRET || "dev-secret-key-change-in-production";
|
||||
|
||||
// Debug: log secret status (remove in production)
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.log("🔐 NextAuth secret:", process.env.NEXTAUTH_SECRET ? "✅ Loaded from .env.local" : "⚠️ Using fallback");
|
||||
console.log(
|
||||
"🔐 NextAuth secret:",
|
||||
process.env.NEXTAUTH_SECRET
|
||||
? "✅ Loaded from .env.local"
|
||||
: "⚠️ Using fallback",
|
||||
);
|
||||
}
|
||||
|
||||
if (!process.env.NEXTAUTH_SECRET && process.env.NODE_ENV === "production") {
|
||||
throw new Error(
|
||||
"NEXTAUTH_SECRET is required in production. Please set it in your environment variables."
|
||||
"NEXTAUTH_SECRET is required in production. Please set it in your environment variables.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,7 +35,9 @@ export const authOptions: NextAuthOptions = {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isValid = await authService.verifyPassword(credentials.password);
|
||||
const isValid = await authService.verifyPassword(
|
||||
credentials.password,
|
||||
);
|
||||
if (!isValid) {
|
||||
return null;
|
||||
}
|
||||
@@ -69,4 +77,3 @@ export const authOptions: NextAuthOptions = {
|
||||
},
|
||||
secret,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user