next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

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

Open Senbonzakura1234 opened this issue 1 year ago • 2 comments

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 avatar Jun 10 '24 02:06 Senbonzakura1234

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

erikash avatar Jun 19 '24 19:06 erikash

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?

Senbonzakura1234 avatar Jun 20 '24 01:06 Senbonzakura1234

any update on this issue?

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!

Senbonzakura1234 avatar Jul 11 '24 07:07 Senbonzakura1234