diff --git a/security/form_login.rst b/security/form_login.rst
index 38ec7ed182d..6f6b14e7fc4 100644
--- a/security/form_login.rst
+++ b/security/form_login.rst
@@ -218,57 +218,12 @@ this by setting ``use_referer`` to true (it defaults to false):
),
));
-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 example, to
-redirect to the URL defined by some ``account`` route, use the following:
-
-.. configuration-block::
-
- .. code-block:: html+twig
-
- {# src/AppBundle/Resources/views/Security/login.html.twig #}
- {% if error %}
-
{{ error.message }}
- {% endif %}
-
-
-
- .. code-block:: html+php
-
-
-
- getMessage() ?>
-
-
-
+Redirecting on Login Failure
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-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``
-option to another value.
+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``
+option to define the route or URL the user is redirected to:
.. configuration-block::
@@ -282,7 +237,8 @@ option to another value.
main:
# ...
form_login:
- target_path_parameter: redirect_url
+ # ...
+ failure_path: login_failure
.. code-block:: xml
@@ -299,7 +255,7 @@ option to another value.
-
+
@@ -314,20 +270,66 @@ option to another value.
'main' => array(
// ...
'form_login' => array(
- 'target_path_parameter' => 'redirect_url',
+ // ...
+ 'failure_path' => 'login_failure',
),
),
),
));
-Redirecting on Login Failure
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Control the Redirect URL from inside the Form
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-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:
+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 successful logins
+and ``_failure_path`` for login errors:
+
+.. configuration-block::
+
+ .. code-block:: html+twig
+
+ {# src/AppBundle/Resources/views/Security/login.html.twig #}
+ {% if error %}
+ {{ error.message }}
+ {% endif %}
+
+
+
+ .. code-block:: html+php
+
+
+
+ getMessage() ?>
+
+
+
+
+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.
+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::
@@ -341,8 +343,8 @@ back to the login form itself. You can set this to a different route (e.g.
main:
# ...
form_login:
- # ...
- failure_path: login_failure
+ target_path_parameter: login_success
+ failure_path_parameter: login_fail
.. code-block:: xml
@@ -359,7 +361,8 @@ back to the login form itself. You can set this to a different route (e.g.
-
+
+
@@ -374,8 +377,8 @@ back to the login form itself. You can set this to a different route (e.g.
'main' => array(
// ...
'form_login' => array(
- // ...
- 'failure_path' => 'login_failure',
+ 'target_path_parameter' => 'login_success',
+ 'failure_path_parameter' => 'login_fail',
),
),
),