Problem/Motivation
The forced redirect on login is very naive, always occurs, and cannot be adjusted from the UI.
When a user requests a password reset, they are logged in then force-redirected to the dashboard if there is one available for them. This makes resetting their password much more difficult.
If a login redirect module like Login Destination is in use, dashboard module's redirect will override that module's redirect.
Steps to reproduce
- Setup a dashboard to be available for a user of a given role.
- Request a password reset as that user.
- Follow the link in the email and submit the form.
Expected behaviour: the user should be presented with a password reset form.
Actual behaviour: the user is redirected to the dashboard.
Proposed resolution
- Do not ever redirect from the password reset login.
- Provide a configuration setting to opt out of the forced redirect so other login redirect modules can be used.
Comments
Comment #2
thejimbirch commentedSome folks are using the ECA module to create custom login workflows.
Here is an excellent example in the feature demo.
https://ecaguide.org/library/use%20case/eca_feature_demo/
Comment #3
johnpitcairn commentedThat's not the point. There are many ways to create login redirects. This module shouldn't blindly override those, especially if it's from a password reset.
Comment #4
thejimbirch commentedOh, I agree with you John! Just adding an additional way that people are currently using for login redirection.
Comment #5
thejimbirch commentedI am running into this working on the Drupal CMS SEO recipe. I am creating an SEO dashboard, and because I am using this module, now all users that login get redirected to the dashboard.
John's proposed resolutions are good. An alternate solution would be to remove all redirection from this module and let other solutions handle that workflow.
Adding Starshot blocker tag.
Comment #7
thejimbirch commentedI created a merge request that removes the redirection completely. For my use case/testing, it appears to be working as expected with no errors or warnings logged.
There are PHPstan errors and failed tests in the pipeline, but I believe they are unrelated.
Comment #8
plopescThe aim of Dashboard module is to provide a better experience for users right after login.
Agree that current implementation could be too aggressive, and alternatives could be discussed.
However, I believe that removing it completely is too much.
Being tagged as a Starshot blocker, we have to take care of it somehow.
Could you please explain your specific needs to try to find a better way to handle login redirects?
Maybe a setting to toggle redirect could be enough for the problematic scenario.
Comment #9
johnpitcairn commentedItem 2 could possibly be met by a simple enable/disable checkbox. Item 1 cannot.
My recommendation would be that if redirection is desired, starshot should use a dedicated configurable login redirect module or ECA rule. We should not rely on a simplistic solution here, it will only wind up needing special case logic that is already solved in contrib. Redirect should be out of scope for this module.
Comment #10
plopescTotally agree that 1 has to be addressed.
My concern was that MR approach to solve the bug was removing one of the main module features.
Comment #11
thejimbirch commentedI am proposing that redirection shouldn't be "one of the main module features". In a composable ecosystem such as Drupal you can rely on the many existing solutions to handle the redirection, and concentrate on the other dashboard features.
ECA is already in Drupal CMS. You could lower the amount of code you have to manage by including an ECA config that handles the redirection. Then it could be turned off or altered by the site owner.
Comment #12
penyaskito@thejimbirch The idea of this module is eventually become part of core, and IMHO the default experience when you log in into drupal core is the raison d'etre of the issue in the ideas queue that ended up being the initiative where this originated.
I'm of course open to allow people creating alternatives, but don't think we should rely on any other module for this, or even a setting. AFAIK now it would be possible to intercept this with
hook_module_implements_alter. So unless we are preventing ECA or other modules to prevent our redirect, I think this is a won't fix (aside of the reset password form, which is definitely a bug)Comment #13
johnpitcairn commentedSo every contrib or custom module or ECA rule or whatever that redirects at login may be broken as soon as dashboard is installed. And all those implementations will have to add implements_alter() code to fix it.
Aren't we aiming to be a lower-code platform? How is somebody who just uses an ECA rule via the UI supposed to deal with this?
Its hard to know what's out there in the wild that will be disrupted - I think this really does need to be controlled by a setting in the UI.
Comment #14
johnpitcairn commentedYes, exactly. Why do we need to handle redirect here at all if it can be done better elsewhere in core, and at the same time introduce people to the power of ECA?
Comment #16
samitk commentedHello,
I have fixed the failed phpunit test cases, Please review.
Thanks
Samit K.
Comment #17
penyaskitoThis is still under discussion.
Comment #18
penyaskitoWe discussed this at DrupalCon with @timplunket and @pameeela.
We agreed that redirecting to the dashboard on login is something that we should do.
We agreed that we should respect any destination argument and NOT redirect in that case.
I think that should solve the password reset form issue too, but in any case we want specific test coverage for that usecase.
Thanks everyone for raising up this concern.
Comment #19
thejimbirch commentedRedirect to the dashboard after login was added to Drupal CMS yesterday using ECA.
https://www.drupal.org/project/drupal_cms/issues/3477300
Comment #20
penyaskitoThat doesn't change that this still needs to happen here. We can reuse some of the test code from there, thanks!
Comment #22
plopescCreated new MR !27 adding exceptions for destination query parameter and one time login links.
It has been interesting because in order to make test compatible with both D10 & D11, we had to add some tricky logic due to #3469309: Use one-time login link instead of user login form in BrowserTestBase tests.
Hope once this is merged the Drupal CMS repository could rely on these redirects instead of custom ones.
Thank you!
Comment #23
jurgenhaasI think the MR !14 is the correct one here as it removes the redirect by the dashboard module entirely. Redirects are now managed by ECA and there's no need for something in here at all. If this module wants to keep the redirect feature for outside Starshot usage, then it should probably be configurable so that it can be turned off in Starshot.
Comment #24
mtiftThis looks like the correct approach to me, too. Thanks, @plopesc!
Comment #26
penyaskitoFixed #3479666: Fix phpcs issues in gitlabCI and rebased with it, so phpcs checks will pass.
Comment #28
penyaskitoMerged!
See #3466196-18: Dashboard should not force redirect on password reset or override other redirects