Problem/Motivation
When logged in as an administrator and visiting /user/[uid]/one-time-login I see the message 'CSRF token validation failed for one-time login generation. User [uid], Target [target], IP [IP]'
Steps to reproduce
- Install module
- Log in as administrator
- Visit /user/1/one-time-login or any similar page
Proposed resolution
I think the problem is here:
https://git.drupalcode.org/project/onetimelogin/-/blob/1.0.5/src/Control...
Why is the module checking that the current user has a CSRF token at this stage? They are logged in and have had their permissions checked, and they are not the user who needs a one time login link.
Thanks for maintaining the module, it's really useful. In the meantime I am reverting to version 1.0.3 which I think is the last version that did not have this bug.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3571741.patch | 1.13 KB | shank115 |
Comments
Comment #2
shank115 commentedI can confirm this issue and reproduce it on a clean install.
The access denied is caused by the CSRF validation inside
OneTimeLoginController::generate()This patch removes the CSRF token validation block from the controller. The route
/user/{user}/one-time-loginis accessed via GET and is already protected by permissions.Comment #3
shank115 commented