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

Redirects back to login page after clicking login button #112

Open
dhsathiya opened this issue Jul 12, 2022 · 16 comments
Open

Redirects back to login page after clicking login button #112

dhsathiya opened this issue Jul 12, 2022 · 16 comments
Assignees
Labels
on hold type/bug something is broken
Milestone

Comments

@dhsathiya
Copy link
Member

I have noticed that when visiting a site after a while and using the Login-with-Google plugin, after clicking the login button the site gets redirected back to the wp-login page again.

Previous observation:
The last time issue occurred, I checked the requests and found that the redirect was a soft redirect - 302. And the network tab showed that it is from Disk Cache

@nitun
Copy link

nitun commented Jul 13, 2022

Hi @abhishekfdd
Please look into this issue and provide an update before EOD.

Keep posting updates on this task.

Thanks,

@aviral-mittal
Copy link

@aviral-mittal aviral-mittal added priority/normal something that should be fixed sooner type/bug something is broken priority/high something that should be prioritised when taking up next issues and removed priority/normal something that should be fixed sooner labels Jul 13, 2022
@abhishekfdd
Copy link
Contributor

@dhsathiya Is there any particular step to reproduce this issue, as I was able to login fine every time?

@aviral-mittal
Copy link

@abhishekfdd As discussed, please try to set a timeout and see if you are able to reproduce the issue.

@dhsathiya
Copy link
Member Author

@abhishekfdd: I was discussing it with @chandrapatel. He has a theory regarding this. Please talk with Chandra once.

@abhishekfdd
Copy link
Contributor

abhishekfdd commented Jul 20, 2022

To replicate:

  • Tried clearing cookie.
  • tried decreasing session timeout
  • setting browser setting to resume with last session.

Nothing worked.

Discussed with @chandrapatel problem seems to be in redirection but still we are not able to replicate the issue.

@nitun
Copy link

nitun commented Jul 20, 2022

Thanks for checking this again.

If anyone faces the same issue, we will report it along with a screencast here.

Keeping this task on hold till that.

@aviral-mittal aviral-mittal added on hold can't reproduce When the issue is not reproducing and removed priority/high something that should be prioritised when taking up next issues labels Aug 2, 2022
@aviral-mittal aviral-mittal assigned elifvish and unassigned abhishekfdd Sep 9, 2022
@aviral-mittal
Copy link

@elifvish Can you take a look at this and figure out a solution?

@aviral-mittal
Copy link

Hi @elifvish Any updates on this?

@elifvish
Copy link
Contributor

elifvish commented Sep 12, 2022

Yes, I was able to reproduce the issue.
The issue is only reproducible when wordpress_logged_in cookie is set and user visits the login page with this reauth=1 in url.
I've few solutions in mind. Will try them today.
cc: @aviral-mittal

@aviral-mittal
Copy link

@elifvish Please update with the solutions tried and if any of them worked.

@elifvish
Copy link
Contributor

elifvish commented Sep 13, 2022

The root issue is that nonce verification fails if a user visits wp-login.php with reatuth=1 in query args and wordpress_logged_in.
This happens as when nonce is created it checks whether the user is logged in or not. And uses the uid as a part of nonce.
Now when login request is sent wp-verify-nonce fails as reauth=1 parameter logs out the user and now when user id is fetched to verify nonce it returns null.

Yesterday I tried a solution of redirection to wp-login.php
it worked but. I thought I should dig deep to check the root cause.

now that I have found it.
The only way to fix this is to redirect or refresh the login page if visited with reauth=1 and wordpress_logged_in cookie set.
I tested the fix.
Will raise a PR soon once I find the best possible location to place the check.

cc: @aviral-mittal

@elifvish elifvish removed the can't reproduce When the issue is not reproducing label Sep 15, 2022
@aviral-mittal aviral-mittal added this to the V 1.2.3 milestone Sep 15, 2022
elifvish added a commit that referenced this issue Sep 16, 2022
GH-112 : Redirects back to login page after clicking login button
@aviral-mittal
Copy link

@Rink9 Need to test this fix as well.

@Rink9
Copy link

Rink9 commented Sep 19, 2022

@aviral-mittal I have cross checked this issue on chrome, firefox, safari browser with clearing all the caches and cookies. Currently it's working as expected on production site on every browsers. And also redirecting back to login page after clicking on login button issue got resolved on production site. We are good to close this issue as it's working fine now.

Screen.Recording.2022-09-19.at.4.00.30.PM.mov

@Rink9 Rink9 closed this as completed Sep 19, 2022
@dhsathiya dhsathiya reopened this May 3, 2023
@dhsathiya dhsathiya assigned gagan0123 and unassigned elifvish May 3, 2023
@dhsathiya
Copy link
Member Author

@gagan0123 Can you please look into this issue? It doesn't seem to be fixed, or it is happening again.
I am sending you a screen recording of the issue as well as an HAR export.

@gagan0123
Copy link
Member

@dhsathiya

Thanks for providing the HAR file for debugging, as the issue is quite difficult to replicate.

From the HAR file I've deduced that for the first login attempt, when you are redirected back to the login page, it gives a 200 response code instead of 302 as it should have.

In code there are only three possible ways in which no error message would appear when the user is redirected back to the login page even on failure.

  1. The already existing cookies for the site, make WordPress believe you are still logged in, and we already have a $user assigned for your login session (Does not seem to be the case in your request)
  2. The returned code or provider parameters are missing when redirected. (Again, not the case in your request)
  3. If the Nonce created for the login session gets expired before, you are redirected back to the login page.

The third one seems plausible since the site you reported it for, uses page level caching.

Now if you are being served a cached version of the login page, in that case the issue of nonce failure can occur whenever the cache is older than the nonce expiration.

Will need to test this hypothesis. Keep you posted on the progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold type/bug something is broken
Projects
None yet
Development

No branches or pull requests

8 participants