Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SvelteKitAuth: Unexpected navigation when user re-login after successful logout #6929

Closed
aakash14goplani opened this issue Mar 12, 2023 · 1 comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@aakash14goplani
Copy link

aakash14goplani commented Mar 12, 2023

Environment

  System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 8.00 GB / 15.41 GB

  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD

  Browsers:
    Edge: Spartan (44.22621.1265.0), Chromium (110.0.1587.69)
    Internet Explorer: 11.0.22621.1

Reproduction URL

Code: https://github.com/aakash14goplani/SvelteKit-Auth0-NextAuth
Demo: https://svelte-kit-auth0-next-auth.vercel.app/

Describe the issue

Context

  • I have implemented a POC in SvelteKit using Auth0 OAuth provider to auto-login user as soon as they hit the URL. I have used signin REST API for this purpose.
  • Accordingly user can logout by clicking logout button that triggers await signOut({ redirect: false, callbackUrl: '${window.location.origin}/app/logout' });

Problem

  • As soon as user hits localhost:4000 -> they are auto logged-in and redirect to home page (/app)
  • Now they click logout button and are redirected to localhost:4000/app/logout i.e., the URL that was specified within callback option of signOut function.
  • Now when user hits localhost:4000 again -> ideally they should land on home page /app, but that's not the case -> they are again redirected to /app/logout. THIS IS THE ISSUE. Post auto-login after successful logout, user is redirected to callback-url that is provided in signOut option.
  • When the user hits localhost:4000 again, this time they will land on home page /app.

Note
In corporate application, we use different OAuth provider and I am facing same issue there as well. So this bug is not limited to any single OAuth provider.

How to reproduce

  1. Open the browser and hit http://localhost:4000
  2. Verify you're successfully logged in and on home page (/app)
  3. Click on Logout button (on header)
  4. For a fraction of second, you'll be redirect to /app/logout and post that on https://authjs.dev/
  5. Now follow step 1 and go back to localhost:4000
  6. After successful login, you're redirected to -> /app/logout -> https://authjs.dev/
  7. Hit localhost:4000 again -> this time you'll be on correct page i.e. /app

Expected behavior

There should not be any unexpected navigation. Once the user logs-out and logs-in back, they should stay on home page and should not be redirected to logout page (or callbackUrl that was provided in signOut option.)

@aakash14goplani aakash14goplani added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Mar 12, 2023
@aakash14goplani
Copy link
Author

@ThangHuuVu @balazsorban44 - can you please look into this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

1 participant