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

signOut function from auth.ts export doesn't reload the client side useSession state #11125

Open
Senbonzakura1234 opened this issue Jun 10, 2024 · 2 comments
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@Senbonzakura1234
Copy link

Senbonzakura1234 commented Jun 10, 2024

Environment

 System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Memory: 5.41 GB / 15.87 GB
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.0.6 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (125.0.2535.92)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    next: 14.2.3 => 14.2.3
    next-auth: 5.0.0-beta.19 => 5.0.0-beta.19
    react: ^18 => 18.3.1

Reproduction URL

https://github.com/Senbonzakura1234/debug-signout-nextauth

Describe the issue

When i signout using the signOut function from auth.ts export, the app redirect to the callbackUrl as expect, but the session state in client does not update, it still displaying content that supposed to be authenicated view only. The content only disappear when i press F5 to fully reload the page.
The legacy signOut function export from next-auth/react still works as expected though

How to reproduce

  • signin the app
  • press btn Go to Sign In Page to redirect to signOut page
  • perform signOut by press btn Confirm Sign out and app will redirect to the callBackUrl

Expected behavior

  • the useSession state have to return unauthenticated
@Senbonzakura1234 Senbonzakura1234 added bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Jun 10, 2024
@erikash
Copy link

erikash commented Jun 19, 2024

I'm currently using
window.location.reload(); in the event handler function as a workaround.

@Senbonzakura1234
Copy link
Author

Senbonzakura1234 commented Jun 20, 2024

I'm currently using window.location.reload(); in the event handler function as a workaround.

@erikash what was the behavior of the legacy signOut func, did they also use window location? How did they clear the local session state?

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

No branches or pull requests

2 participants