nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
22.87k stars 3.08k forks source link

newUser page is always called even if user is not new on Google or Facebook Login #10890

Open seaver-choy opened 1 month ago

seaver-choy commented 1 month ago

Environment

OS: Mac Sonoma 14.4.1
Node: 21.7.3
"next": "14.0.3",
"next-auth": "^4.24.5",
"@next-auth/mongodb-adapter": "^1.1.3",

Reproduction URL

https://github.com/callbackph/callback-sample-repository/blob/master/auth.ts

Describe the issue

  1. Declared a page for new-user with Google OR Facebook Login with expectation that it only gets called when sign up.
    pages: {
    signIn: '/register',
    verifyRequest: '/auth/verify-request',
    newUser: '/auth/new-user',
    },
  2. using await signIn the first time, user document gets created, get redirected to newUser page.
  3. Logout
  4. using await signIn calls STILL go to newUser page when using Google or Facebook Login

How to reproduce

  1. Use Sign In on OAuth Providers ✅
  2. Redirect to newUser Page ✅
  3. Logout ✅
  4. Resign In with OAuth Providers, newUser page is still redirected to. ❌

Expected behavior

  1. Use Sign in on OAuth Providers
  2. Redirect to newUser page
  3. Logout
  4. Resign In with OAuth Providers, newUser page is NOT redirected to.
ndom91 commented 3 weeks ago

Unfortunately I can't reproduce this with the example app.

Could you try to put together a minimal reproduction? :pray: