You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using next js in the app router method, and the version is 14.2.5.
The version of next auth is version 4.24.7.
I'm working on signIn using the credential provider, and there's an unknown error. The console.log doesn't run at all in the authorize function in the credential provider. Even when I place console.log at the top of the function, it doesn't run at all. However, console.logs in callback functions like jwt and session run well.
Does anyone know the cause?
here is my code and log
import{NextAuthOptions}from'next-auth';importGoogleProviderfrom'next-auth/providers/google';importCredentialsProviderfrom'next-auth/providers/credentials';import{and,eq}from'drizzle-orm';import{db,schema}from'@/db';exportconstauthOptions: NextAuthOptions={secret: process.env.NEXTAUTH_SECRET,pages: {signIn: '/login',},session: {strategy: 'jwt',},providers: [GoogleProvider({clientId: process.env.GOOGLE_CLIENT_ID??'',clientSecret: process.env.GOOGLE_CLIENT_SECRET??'',}),CredentialsProvider({credentials: {email: {label: 'email',type: 'email',placeholder: 'please enter email'},password: {label: 'password',type: 'password'},},// eslint-disable-next-line @typescript-eslint/no-explicit-anyasyncauthorize(credentials): Promise<any>{
console.log('run authorize console.log');if(!credentials?.email||!credentials?.password){thrownewError('please enter the email and password');}constuser=awaitdb.select({userId: schema.usersTable.userId,email: schema.usersTable.email,name: schema.usersTable.nickname,}).from(schema.usersTable).where(and(eq(schema.usersTable.email,credentials.email),eq(schema.usersTable.password,credentials.password))).get();if(!user){thrownewError('no user info');}console.log('authorize user:',user);returnuser;},}),],callbacks: {asyncjwt({ token, user, session }){console.log('jwt callback',{ token, user, session });returntoken;},asyncsession({ session, token, user }){console.log('session callback',{ session, token, user });return{user: {
...session.user,nickname: session.user.name||session.user.nickname,email: session.user.email,},};},},};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using next js in the app router method, and the version is 14.2.5.
The version of next auth is version 4.24.7.
I'm working on signIn using the credential provider, and there's an unknown error. The
console.log
doesn't run at all in the authorize function in the credential provider. Even when I placeconsole.log
at the top of the function, it doesn't run at all. However,console.logs
in callback functions likejwt
andsession
run well.Does anyone know the cause?
here is my code and log
Beta Was this translation helpful? Give feedback.
All reactions