add users to data seed and add pw auth

This commit is contained in:
StephDietz
2023-09-20 10:49:36 -05:00
parent c51ac1dd61
commit 91c8bfac61
8 changed files with 921 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
import NextAuth from 'next-auth/next';
import CredentialsProvider from 'next-auth/providers/credentials';
// import bcrypt from 'bcryptjs';
import bcrypt from 'bcrypt';
import { fetchUser } from '../../../lib/data';
export const authOptions = {
@@ -14,16 +14,17 @@ export const authOptions = {
try {
const user = await fetchUser(email);
console.log('user: ', user);
if (!user) {
return null;
}
// const passwordsMatch = await bcrypt.compare(password, user.password);
const passwordsMatch = await bcrypt.compare(password, user.password);
// if (!passwordsMatch) {
// return null;
// }
if (!passwordsMatch) {
console.log('Passwords do not match');
return null;
}
return user;
} catch (error) {