NextAuth issue
Unanswered
Transvaal lion posted this in #help-forum
Transvaal lionOP
NextAuth authorize function doesnt work. Could you please help me
import users from "@/lib/users";
import NextAuth, { NextAuthOptions } from "next-auth";
import CredentialsProvider from 'next-auth/providers/credentials';
const authOptions: NextAuthOptions = {
providers: [
CredentialsProvider({
name: 'credentials',
credentials: {
email: {},
password: {},
},
async authorize(credentials) {
const foundEmail = users.find((user)=>user.email===credentials?.email);
if(!foundEmail){
return null;
}
if(foundEmail.password === credentials?.password){
return {
id:foundEmail.username,
...foundEmail
};
}
return {
id: "1",
}
},
}),
],
session: {
strategy: 'jwt'
},
secret: process.env.NEXTAUTH_SECRET,
pages: {
signIn: '/auth/login',
},
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };1 Reply
Transvaal lionOP
I enter an email and password that is not included in users, it does not give any error etc and the session is null.