I see this error with the app, reported by NextJS, please fix it. The er
This commit is contained in:
Binary file not shown.
Binary file not shown.
+2
-30
@@ -9,36 +9,8 @@ export const authConfig = {
|
|||||||
signIn: '/login',
|
signIn: '/login',
|
||||||
},
|
},
|
||||||
providers: [
|
providers: [
|
||||||
Credentials({
|
// The Credentials provider logic has been moved to src/auth.ts
|
||||||
async authorize(credentials) {
|
// to prevent the database module from being bundled with middleware.
|
||||||
const parsedCredentials = z
|
|
||||||
.object({ email: z.string().email(), password: z.string().min(1) })
|
|
||||||
.safeParse(credentials);
|
|
||||||
|
|
||||||
if (parsedCredentials.success) {
|
|
||||||
const { email, password } = parsedCredentials.data;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const userStmt = db.prepare('SELECT * FROM users WHERE email = ?');
|
|
||||||
const user = userStmt.get(email) as any;
|
|
||||||
|
|
||||||
if (!user) return null;
|
|
||||||
|
|
||||||
// WARNING: Storing passwords in plaintext is insecure.
|
|
||||||
// This is for demonstration purposes only.
|
|
||||||
// In a real application, you MUST hash and salt passwords.
|
|
||||||
const passwordsMatch = password === user.password;
|
|
||||||
|
|
||||||
if (passwordsMatch) return user;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
callbacks: {
|
callbacks: {
|
||||||
authorized({ auth, request: { nextUrl } }) {
|
authorized({ auth, request: { nextUrl } }) {
|
||||||
|
|||||||
+38
-1
@@ -1,7 +1,44 @@
|
|||||||
|
|
||||||
import NextAuth from 'next-auth';
|
import NextAuth from 'next-auth';
|
||||||
import { authConfig } from './auth.config';
|
import { authConfig } from './auth.config';
|
||||||
|
import Credentials from 'next-auth/providers/credentials';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import db from '@/lib/db';
|
||||||
|
|
||||||
export const { handlers, auth, signIn, signOut } = NextAuth(authConfig);
|
export const { handlers, auth, signIn, signOut } = NextAuth({
|
||||||
|
...authConfig,
|
||||||
|
providers: [
|
||||||
|
Credentials({
|
||||||
|
async authorize(credentials) {
|
||||||
|
const parsedCredentials = z
|
||||||
|
.object({ email: z.string().email(), password: z.string().min(1) })
|
||||||
|
.safeParse(credentials);
|
||||||
|
|
||||||
|
if (parsedCredentials.success) {
|
||||||
|
const { email, password } = parsedCredentials.data;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const userStmt = db.prepare('SELECT * FROM users WHERE email = ?');
|
||||||
|
const user = userStmt.get(email) as any;
|
||||||
|
|
||||||
|
if (!user) return null;
|
||||||
|
|
||||||
|
// WARNING: Storing passwords in plaintext is insecure.
|
||||||
|
// This is for demonstration purposes only.
|
||||||
|
// In a real application, you MUST hash and salt passwords.
|
||||||
|
const passwordsMatch = password === user.password;
|
||||||
|
|
||||||
|
if (passwordsMatch) return user;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
export const runtime = "nodejs";
|
export const runtime = "nodejs";
|
||||||
|
|||||||
Reference in New Issue
Block a user