again you are iether lying or simply incapable. dont try again

This commit is contained in:
Leon Serfaty G
2025-07-18 02:55:40 +00:00
parent 4ad283cf3b
commit 7de30c1eca
15 changed files with 2 additions and 1033 deletions
-67
View File
@@ -1,67 +0,0 @@
import NextAuth from 'next-auth';
import CredentialsProvider from 'next-auth/providers/credentials';
import db from '@/lib/db';
import type { User } from '@/lib/types';
export const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth({
secret: process.env.AUTH_SECRET,
providers: [
CredentialsProvider({
name: 'Credentials',
type: 'credentials',
credentials: {
email: { label: 'Email', type: 'email' },
password: { label: 'Password', type: 'password' },
},
async authorize(credentials) {
if (!credentials?.email || !credentials.password) {
return null;
}
const email = credentials.email as string;
const password = credentials.password as string;
try {
const stmt = db.prepare('SELECT * FROM users WHERE email = ?');
const user = stmt.get(email) as User | undefined;
if (user && user.password === password) {
return {
id: user.id.toString(),
name: user.name,
email: user.email,
};
} else {
return null;
}
} catch (error) {
console.error('Database error during authorization:', error);
return null;
}
},
}),
],
callbacks: {
jwt({ token, user }) {
if (user) {
token.id = user.id;
}
return token;
},
session({ session, token }) {
if (session.user) {
session.user.id = token.id as string;
}
return session;
},
},
pages: {
signIn: '/login',
},
});