8000 Added caution about using is_granted in error pages · symfony/symfony-docs@0d82503 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d82503

Browse files
committed
Added caution about using is_granted in error pages
1 parent 180bf50 commit 0d82503

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cookbook/controller/error_pages.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ end-user, create a new template located at
5050
</body>
5151
</html>
5252

53+
.. caution::
54+
55+
You **must not** use ``is_granted`` in your error pages, because the
56+
router runs before the firewall. If the router throws an exception (for
57+
instance, when the route does not match), the error page is not behind a
58+
firewall and ``app.user`` is not defined.
59+
5360
.. tip::
5461

5562
If you're not familiar with Twig, don't worry. Twig is a simple, powerful

0 commit comments

Comments
 (0)
0