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

Appearance settings

Commit adf6f36

Browse filesBrowse files
committed
revert #5271 on the 2.6 branch
1 parent 3653b67 commit adf6f36
Copy full SHA for adf6f36

File tree

1 file changed

+13
-9
lines changed
Filter options

1 file changed

+13
-9
lines changed

‎best_practices/security.rst

Copy file name to clipboardExpand all lines: best_practices/security.rst
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ more advanced use-case, you can always do the same security check in PHP:
221221

222222
.. code-block:: php
223223
224-
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
225-
226-
// ...
227-
228224
/**
229225
* @Route("/{id}/edit", name="admin_post_edit")
230226
*/
@@ -238,7 +234,16 @@ more advanced use-case, you can always do the same security check in PHP:
238234
}
239235
240236
if (!$post->isAuthor($this->getUser())) {
241-
throw new AccessDeniedException();
237+
$this->denyAccessUnlessGranted('edit', $post);
238+
239+
// or without the shortcut:
240+
//
241+
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
242+
// ...
243+
//
244+
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
245+
// throw $this->createAccessDeniedException();
246+
// }
242247
}
243248
244249
// ...
@@ -327,10 +332,6 @@ via the even easier shortcut in a controller:
327332

328333
.. code-block:: php
329334
330-
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
331-
332-
// ...
333-
334335
/**
335336
* @Route("/{id}/edit", name="admin_post_edit")
336337
*/
@@ -342,6 +343,9 @@ via the even easier shortcut in a controller:
342343
343344
// or without the shortcut:
344345
//
346+
// use Symfony\Component\Security\Core\Exception\AccessDeniedException;
347+
// ...
348+
//
345349
// if (!$this->get('security.authorization_checker')->isGranted('edit', $post)) {
346350
// throw $this->createAccessDeniedException();
347351
// }

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.