-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix event listener race condition on login-form #36286
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense :)
Thanks for your pull request 👍 I think that could explain this error: #32387 But the error shown to the user is a bit different. |
But this points to V2?! But maybe a similar error? |
Ah, LoginV2 uses the same script, sorry. In this case we should add „disabled“ to the V2 template as well? |
Well spotted ;) |
😉 I guess it makes sense, looking at the V2 form we have the same situation here:
so that could very well lead to the same problem. I’ll take a look at this. |
Signed-off-by: Marcel Müller <[email protected]>
618a151
to
bbb490d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
/backport to stable25 |
/backport to stable24 |
/backport to stable25 |
/backport to stable24 |
The backport to stable25 failed. Please do this backport manually. |
The backport to stable24 failed. Please do this backport manually. |
/backport to stable25 |
/backport to stable24 |
The backport to stable24 failed. Please do this backport manually. |
Not sure we need a backport to stable24, because there it is a link, instead of a form: server/core/templates/loginflow/authpicker.php Lines 49 to 51 in 7003a40
And there's no event handler: https://github.com/nextcloud/server/blob/stable24/core/js/login/authpicker.js But I'm not sure what the reason for the change was in the first place. |
I guess 25 is fine then. |
Summary
We received reports about the error "State token does not match" when trying to login with talk-ios (see nextcloud/talk-ios#1017). I have seen this error myself from time to time, but wasn't able to pinpoint it to when exactly it happens. I took a closer look at the requests / responses received and noticed, that usually we should see something like this
but in some cases it was just like this
so without any query parameters. The login process itself (username, password) does work fine, but fails after granting access with the error mentioned above.
The page itself is rendered correctly, so the forms actions include the parameters as seen in the first request above. As this won't work natively (at least not on iOS), we need a small javascript snippet (
authpicker.js
) to to a redirect, instead of a the native browser action. Problem is that the listener for this to happen is added when the document is ready, but the user is actually able to press "Log in" before the listener is added, therefore doing a native browser action with the query parameters removed.How to test:
server/core/js/login/authpicker.js
Lines 9 to 12 in 791a182
Because this code is still using jQuery and therefore considered legacy, I went for disabling the button until the corresponding jQuery code ran.
CC: @Ivansss
Checklist