Skip to content

Add the _failure_path hidden field in template #7620

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

Merged
merged 3 commits into from
Apr 15, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor rewords
  • Loading branch information
javiereguiluz authored Mar 14, 2017
commit 1fc80af9c9fd41ca9c76d1931503ca5c3fb99a88
18 changes: 7 additions & 11 deletions security/form_login.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,9 @@ this by setting ``use_referer`` to true (it defaults to false):
Redirecting on Login Failure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In addition to redirecting the user after a successful login, you can also set
the URL that the user should be redirected to after a failed login (e.g. an
invalid username or password was submitted). By default, the user is redirected
back to the login form itself. You can set this to a different route (e.g.
``login_failure``) with the following config:
After a failed login (e.g. an invalid username or password was submitted), the
user is redirected back to the login form itself. Use the ``failure_path``
Copy link
Member

Choose a reason for hiding this comment

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

_failure_path ?

Copy link
Member

Choose a reason for hiding this comment

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

The parameter with the leading _ is when using the hidden form field, right? Otherwise you don't have to prefix the _.

option to define the route or URL the user is redirected to:

.. configuration-block::

Expand Down Expand Up @@ -283,9 +281,8 @@ Control the Redirect URL from inside the Form
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also override where the user is redirected to via the form itself by
including a hidden field with the name ``_target_path`` for success and
``_failure_path`` for failure. For example, to redirect to the URL defined
by some ``account`` route, use the following:
including a hidden field with the name ``_target_path`` for successful logins
and ``_failure_path`` for login errors:

.. configuration-block::

Expand Down Expand Up @@ -331,9 +328,8 @@ by some ``account`` route, use the following:

Now, the user will be redirected to the value of the hidden form field. The
value attribute can be a relative path, absolute URL, or a route name.
You can even change the name of the hidden form field by changing the
``target_path_parameter`` and ``failure_path_parameter`` options to another
value.
The name of the hidden fields in the login form is also configurable using the
``target_path_parameter`` and ``failure_path_parameter`` options of the firewall.

.. configuration-block::

Expand Down