@@ -209,7 +209,7 @@ user to be logged in to access this URL:
209
209
# ...
210
210
firewalls :
211
211
# ...
212
-
212
+
213
213
access_control :
214
214
# require ROLE_ADMIN for /admin*
215
215
- { path: ^/admin, roles: ROLE_ADMIN }
@@ -676,7 +676,7 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
676
676
# ...
677
677
firewalls :
678
678
# ...
679
-
679
+
680
680
access_control :
681
681
# require ROLE_ADMIN for /admin*
682
682
- { path: ^/admin, roles: ROLE_ADMIN }
@@ -870,9 +870,9 @@ in this chapter).
870
870
Be careful with this in your layout or on your error pages! Because of
871
871
some internal Symfony details, to avoid broken error pages in the ``prod ``
872
872
environment, wrap calls in these templates with a check for ``app.user ``:
873
-
873
+
874
874
.. code-block :: html+jinja
875
-
875
+
876
876
{% if app.user and is_granted('ROLE_ADMIN') %}
877
877
878
878
Securing other Services
@@ -1036,7 +1036,7 @@ the User object, and use the ``isGranted`` method (or
1036
1036
1037
1037
// boo :(. Never check for the User object to see if they're logged in
1038
1038
if ($this->getUser()) {
1039
-
1039
+
1040
1040
}
1041
1041
1042
1042
Retrieving the User in a Template
@@ -1055,7 +1055,7 @@ key:
1055
1055
1056
1056
.. code-block :: html+php
1057
1057
1058
- <?php if ($view['security']->isGranted('IS_AUTHENTICATED_FULLY')): ?>
1058
+ <?php if ($view['security']->isGranted('IS_AUTHENTICATED_FULLY')): ?>
1059
1059
<p>Username: <?php echo $app->getUser()->getUsername() ?></p>
1060
1060
<?php endif; ?>
1061
1061
@@ -1148,7 +1148,7 @@ Next, you'll need to create a route for this URL (but not a controller):
1148
1148
return $collection;
1149
1149
1150
1150
And that's it! By sending a user to ``/logout `` (or whatever you configure
1151
- the ``path `` to be), Symfony will un-authenticate the current user. and
1151
+ the ``path `` to be), Symfony will un-authenticate the current user. and
1152
1152
redirect them the homepage (the value defined by ``target ``).
1153
1153
1154
1154
Once the user has been logged out, they will be redirected to whatever path
@@ -1180,6 +1180,9 @@ in the following way from a controller::
1180
1180
1181
1181
$user->setPassword($encoded);
1182
1182
1183
+ .. versionadded :: 2.6
1184
+ The ``security.password_encoder `` service was introduced in Symfony 2.6.
1185
+
1183
1186
In order for this to work, just make sure that you have the encoder for your
1184
1187
user class (e.g. ``AppBundle\Entity\User ``) configured under the ``encoders ``
1185
1188
key in ``app/config/security.yml ``.
0 commit comments