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

Attempting to log out right after logging in does not work #300

Open
athrael-soju opened this issue Apr 3, 2024 · 2 comments
Open

Attempting to log out right after logging in does not work #300

athrael-soju opened this issue Apr 3, 2024 · 2 comments

Comments

@athrael-soju
Copy link

athrael-soju commented Apr 3, 2024

If you click log out right after logging in it will not work.

When checking the network in devtools, the call being made is to the login api
image

If we log inside auth.config.ts we can see that the redirect pathname is still /login until the page is refreshed, or user sends a message (which will cause a re-render). Then the logout will work fine and pathname will be /

Commenting out this code seems to fix it, but I don't have the time to verify.

  // if (isLoggedIn) {        
  //   if (isOnLoginPage || isOnSignupPage) {
  //     return Response.redirect(new URL('/', nextUrl))
  //   }
  // }

I will try find the time to fix it properly, but if anyone gets to it first, even better. Should be a quick fix.

@gchust
Copy link

gchust commented Apr 4, 2024

I faced the same issue here.
In fact, not only the logout is not working correctly, the clear history action is also not working just after the login!

Commenting out this code seems to fix it, but I don't have the time to verify.

This is not working, it will block the redirect after the login completly, and user may think he/she has not login yet...

I am fixing this issue for the moment.

@gchust
Copy link

gchust commented Apr 4, 2024

I have created a PR for this issue #301

The root cause is Response.redirect(new URL('/', nextUrl)) is a 302 redirection, makes Post method not working correctly.

Traditionally a 302 was used for a temporary redirect, and a 301 for a permanent redirect, but many browsers changed the request method of the redirect to GET, regardless of the original method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants