Open
Conversation
markstory
reviewed
Apr 17, 2026
The helper always has a sensible default ('/'), so accepting null as an
explicit argument added no value and required a dead null-check branch.
The return type stays nullable because Controller::redirect() itself can
return null when a beforeRedirect event cancels the redirect.
Member
Author
|
Yeah, sounds right. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds a small controller-level helper to make the safe post-login redirect path the obvious one:
Internally this builds on the existing safe redirect parsing already present in the plugin via
AuthenticationService::getLoginRedirect()andAuthenticationComponent::getLoginRedirect().Why
The plugin already does the hard part correctly:
AuthenticationService::getLoginRedirect()rejects redirect targets with aschemeorhostThe gap is ergonomics.
In real applications, controller code often ends up doing this instead:
or this:
The second version is safe, but it is a two-step pattern that is easy to bypass or forget. A first-class helper makes the secure path shorter and more discoverable.
What this adds
This PR adds:
Behavior:
getLoginRedirect($default)$defaultwhen no valid redirect is availableExample:
We could release this as a new minor.