Error
Something went wrong.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
import { handlers, auth, signIn, signOut } from '@/auth';
|
import { handlers } from '@/auth';
|
||||||
|
|
||||||
export const { GET, POST } = handlers;
|
export const { GET, POST } = handlers;
|
||||||
|
|
||||||
export { auth, signIn, signOut };
|
|
||||||
|
|
||||||
export const runtime = "nodejs";
|
export const runtime = "nodejs";
|
||||||
|
|||||||
+12
-17
@@ -17,28 +17,23 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
|
|||||||
if (parsedCredentials.success) {
|
if (parsedCredentials.success) {
|
||||||
const { email, password } = parsedCredentials.data;
|
const { email, password } = parsedCredentials.data;
|
||||||
|
|
||||||
try {
|
const userStmt = db.prepare('SELECT * FROM users WHERE email = ?');
|
||||||
const userStmt = db.prepare('SELECT * FROM users WHERE email = ?');
|
const user = userStmt.get(email) as any;
|
||||||
const user = userStmt.get(email) as any;
|
|
||||||
|
|
||||||
if (!user) return null;
|
if (!user) return null;
|
||||||
|
|
||||||
// WARNING: Storing passwords in plaintext is insecure.
|
// WARNING: Storing passwords in plaintext is insecure.
|
||||||
// This is for demonstration purposes only.
|
// This is for demonstration purposes only.
|
||||||
// In a real application, you MUST hash and salt passwords.
|
// In a real application, you MUST hash and salt passwords.
|
||||||
const passwordsMatch = password === user.password;
|
const passwordsMatch = password === user.password;
|
||||||
|
|
||||||
if (passwordsMatch) {
|
if (passwordsMatch) {
|
||||||
// The user object returned here will be encoded in the JWT.
|
// The user object returned here will be encoded in the JWT.
|
||||||
return { id: user.id, name: user.name, email: user.email };
|
return { id: user.id, name: user.name, email: user.email };
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e)
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Invalid credentials');
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user