Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding new TargetPathTrait to get/set the authentication "target_path" #17714

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

Closed
wants to merge 2 commits into from

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR not yet...

Hi guys!

This is a small guy. Basically, when you're doing custom auth (i.e. a guard authenticator), it's common to need the previous URL the user tried to get to (i.e. the "target path"). It's not much work to do it now, but it's very abstract - needing to know a weird string pattern. This just wraps that weirdness up in a simple function (getTargetPath()).

Thanks!

* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Http\Helper;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why "Helper" instead of the more common "Util" namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason :) I changed to Util

…" URL to the session

This allows this method to be easily re-used inside custom authentication schemes.
@weaverryan
Copy link
Member Author

ping @symfony/deciders

@dunglas
Copy link
Member

dunglas commented Feb 22, 2016

👍

trait TargetPathTrait
{
/**
* Set the target path the user should be redirected to after authentication.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets

@fabpot
Copy link
Member

fabpot commented Mar 1, 2016

👍

@xabbuh
Copy link
Member

xabbuh commented Mar 1, 2016

👍

Status: Reviewed

@fabpot
Copy link
Member

fabpot commented Mar 2, 2016

Thank you @weaverryan.

@fabpot fabpot closed this in 5d6a6b3 Mar 2, 2016
@weaverryan weaverryan deleted the target-path-trait branch March 6, 2016 21:49
fabpot added a commit that referenced this pull request Mar 25, 2016
This PR was merged into the 3.1-dev branch.

Discussion
----------

[Guard] fix minimum required Seucirty Http version

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17714
| License       | MIT
| Doc PR        |

Otherwise, the `TargetPathTrait` is not available.

Commits
-------

952bf01 [Guard] fix minimum required Seucirty Http version
@fabpot fabpot mentioned this pull request May 13, 2016
@rvanlaak
Copy link
Contributor

@weaverryan I find myself setting this path quite often manually, so this is a nice one. Will it allow us to set the target_path by using the Trait you provided even if the InteractiveLoginEvent was not triggered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants