Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reworded the article about form login redirects#8192

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@javiereguiluz
Copy link
Member

Now that form login redirects have been fully fixed (seesymfony/symfony#23580) I thought about updating this article, specially its structure.

All changes are simple rewordings, except this one: previously, the article said that you can use a Symfony route name as the value of the_target_path parameter in the query string or the hidden form field. But if you check the code of this feature, it looks like you can't because we use the value of that parameter "as is" to redirect, so it must be a relative/absolute URL, right?

protectedfunctiondetermineTargetUrl(Request$request){if ($this->options['always_use_default_target_path']) {return$this->options['default_target_path'];    }// We redirect directly to the value of the parameter, so it can't be a route name, right ????if ($targetUrl =$request->get($this->options['target_path_parameter'],null,true)) {return$targetUrl;    }// ...}

@yceruto
Copy link
Member

yceruto commentedJul 19, 2017
edited
Loading

Please, could you take account this commentsymfony/symfony#17529 (comment) in this PR? thanks.

@yceruto
Copy link
Member

See@dmaicher'scomment which also explains the only use case of this option:

So it only works for use cases where the form POST comes from a different page than /login
Maybe its meant to be used if you have the login form embedded in the header of your page or something. So once you logged in you get redirected back to the page where the POST came from.

@javiereguiluz
Copy link
MemberAuthor

@yceruto thanks for letting me know this. I've updated the article. Cheers!

@xabbuhxabbuh added this to the2.7 milestoneJul 21, 2017
Using a:doc:`form login</security/form_login_setup>` for authentication is a
common, and flexible, method for handling authentication in Symfony. This
article explains how to customize the URL which the user is redirected to after
a successful or failure login. Check out the full
Copy link
Member

Choose a reason for hiding this comment

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

"[...] or failed login."?

article explains how to customize the URL which the user is redirected to after
a successful or failure login. Check out the full
:doc:`form login configuration reference</reference/configuration/security>` to
learn about the rest of possible customizations.
Copy link
Member

Choose a reason for hiding this comment

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

[...] of the possile customization options.

in several ways.
By default, the form will redirect to the URL the user requested (i.e. the URL
which triggered the login form being shown). For example, if the user requested
``http://www.example.com/admin/post/18/edit``, then after they successfully log
Copy link
Member

Choose a reason for hiding this comment

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

[...] they have successfully logged in, [...]

``default_security_target`` route use the following config:
Define the``default_security_target`` option to changethe pagewherethe user
is redirected toif no previous page was stored in the session. The value can be
relative/absolute URL or a Symfony route name:
Copy link
Member

Choose a reason for hiding this comment

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

[...] can be a relative/absolute [...]

Copy link
Member

Choose a reason for hiding this comment

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

the leading whitespace must be removed by the way (see the build failure)


..code-block::html+twig

{# src/AppBundle/Resources/views/Security/login.html.twig #}
Copy link
Member

Choose a reason for hiding this comment

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

{# app/Resources/views/security/login.html.twig #}


..code-block::html+php

<!-- src/AppBundle/Resources/views/Security/login.html.php -->
Copy link
Member

Choose a reason for hiding this comment

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

<!-- app/Resources/views/security/login.html.php -->

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
..note::

The referrer URL is only used when is different from the URL generated by
Copy link
Member

Choose a reason for hiding this comment

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

[...] when it is [...]

..note::

The referrer URL is only used when is different from the URL generated by
the ``login_path`` route, to avoid a redirection loop.
Copy link
Member

Choose a reason for hiding this comment

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

the comma should be removed


..code-block::html+twig

{# src/AppBundle/Resources/views/Security/login.html.twig #}
Copy link
Member

@xabbuhxabbuhJul 21, 2017
edited
Loading

Choose a reason for hiding this comment

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

{# app/Resources/views/security/login.html.twig #}

<input type="hidden" name="_failure_path" value="login" />
{# ... #}

<input type="hidden" name="_failure_path" value="{{ path('forgot-password') }}" />
Copy link
Member

Choose a reason for hiding this comment

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

forgot_password

<input type="hidden" name="_failure_path" value="login" />
// ...

<input type="hidden" name="_failure_path" value="<?php echo $view['router']->generate('forgot-password') ?>" />
Copy link
Member

Choose a reason for hiding this comment

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

forgot_password


<input type="hidden" name="_target_path" value="account" />
<input type="hidden" name="_failure_path" value="login" />
// ...
Copy link
Member

Choose a reason for hiding this comment

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

<!-- ... -->


..code-block::html+php

<!-- src/AppBundle/Resources/views/Security/login.html.php -->
Copy link
Member

Choose a reason for hiding this comment

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

<!-- app/Resources/views/security/login.html.php -->


..code-block::html+twig

{# src/AppBundle/Resources/views/Security/login.html.twig #}
Copy link
Member

Choose a reason for hiding this comment

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

{# app/Resources/views/security/login.html.twig #}


<!-- src/AppBundle/Resources/views/Security/login.html.php -->
<form action="<?php echo $view['router']->generate('login') ?>" method="post">
// ...
Copy link
Member

Choose a reason for hiding this comment

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

<!-- ... -->


..code-block::html+php

<!-- src/AppBundle/Resources/views/Security/login.html.php -->
Copy link
Member

Choose a reason for hiding this comment

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

<!-- app/Resources/views/security/login.html.php -->

{# ... #}

<input type="hidden" name="go_to" value="{{ path('dashboard') }}" />
<input type="hidden" name="back_to" value="{{ path('forgot-password') }}" />
Copy link
Member

Choose a reason for hiding this comment

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

forgot_password

// ...

<input type="hidden" name="go_to" value="<?php echo $view['router']->generate('dashboard') ?>" />
<input type="hidden" name="back_to" value="<?php echo $view['router']->generate('forgot-password') ?>" />
Copy link
Member

Choose a reason for hiding this comment

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

forgot_password

@javiereguiluz
Copy link
MemberAuthor

@xabbuh thank you for the time you dedicated to review this. As usual, a great review! Thanks.

@xabbuh
Copy link
Member

Thank you Javier.

xabbuh added a commit that referenced this pull requestJul 21, 2017
…uiluz)This PR was squashed before being merged into the 2.7 branch (closes#8192).Discussion----------Reworded the article about form login redirectsNow that form login redirects have been fully fixed (seesymfony/symfony#23580) I thought about updating this article, specially its structure.All changes are simple rewordings, except this one: previously, the article said that you can use a Symfony route name as the value of the `_target_path` parameter in the query string or the hidden form field. But if you check the code of this feature, it looks like you can't because we use the value of that parameter "as is" to redirect, so it must be a relative/absolute URL, right?```phpprotected function determineTargetUrl(Request $request){    if ($this->options['always_use_default_target_path']) {        return $this->options['default_target_path'];    }    // We redirect directly to the value of the parameter, so it can't be a route name, right ????    if ($targetUrl = $request->get($this->options['target_path_parameter'], null, true)) {        return $targetUrl;    }    // ...}```Commits-------5015723 Reworded the article about form login redirects
xabbuh added a commit that referenced this pull requestJul 21, 2017
@xabbuhxabbuh closed thisJul 21, 2017
xabbuh added a commit that referenced this pull requestJul 21, 2017
* 2.8: (37 commits)  [#8192] use path() in PHP templates  Reworded the article about form login redirects  Explained the edge-case where the use_referer option doesn't work  [#7572] fix wording  [#7585] remove trailing whitespaces  [#7585] minor rewording  Fixed a typo  Fixed a typo  Update parent_services for tip consistency  [#7685] use the method role  Minor change  Updating doc to specify priority of default normalizer  [#7767] remove trailing space  [#7767] replace "options" with "entry_options"  [#7767] minor rewording  [#8047] add inline code comment  Fixed the issue in a different way  Jquery datePicker syntax update  [#8104] minor rewording  Add more precision about automatic provider assignation  ...
xabbuh added a commit that referenced this pull requestJul 21, 2017
* 3.2: (38 commits)  [#8192] use path() in PHP templates  Reworded the article about form login redirects  Explained the edge-case where the use_referer option doesn't work  [#7572] fix wording  [#7585] remove trailing whitespaces  [#7585] minor rewording  Fixed a typo  Fixed a typo  Update parent_services for tip consistency  [#7685] use the method role  Minor change  Updating doc to specify priority of default normalizer  [#7767] remove trailing space  [#7767] replace "options" with "entry_options"  [#7767] minor rewording  [#8047] add inline code comment  Fixed the issue in a different way  Jquery datePicker syntax update  Fix framework instantiation in event-dispatcher  [#8104] minor rewording  ...
xabbuh added a commit that referenced this pull requestJul 21, 2017
* 3.3: (46 commits)  [#8192] use path() in PHP templates  Reworded the article about form login redirects  Update Flex documentation with latest structure  Explained the edge-case where the use_referer option doesn't work  [#7572] fix wording  [#7585] remove trailing whitespaces  [#7585] minor rewording  Fixed a typo  Fixed a typo  Update parent_services for tip consistency  [#7685] use the method role  Minor change  Updating doc to specify priority of default normalizer  [#7767] remove trailing space  [#7767] replace "options" with "entry_options"  [#7767] minor rewording  [#8047] add inline code comment  Fixed the issue in a different way  Jquery datePicker syntax update  Fix framework instantiation in event-dispatcher  ...
xabbuh added a commit that referenced this pull requestJul 21, 2017
* 3.4: (48 commits)  [#8192] use path() in PHP templates  Reworded the article about form login redirects  Update Flex documentation with latest structure  Explained the edge-case where the use_referer option doesn't work  [#7572] fix wording  [#7585] remove trailing whitespaces  [#7585] minor rewording  Fixed a typo  Fixed a typo  Update parent_services for tip consistency  [#7685] use the method role  Minor change  Updating doc to specify priority of default normalizer  [#7767] remove trailing space  [#7767] replace "options" with "entry_options"  [#7767] minor rewording  [#8047] add inline code comment  Fixed the issue in a different way  Jquery datePicker syntax update  Fix framework instantiation in event-dispatcher  ...
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh left review comments

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

4 participants

@javiereguiluz@yceruto@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp