Skip to content

Commit 6473d6c

Browse files
committed
Finished the docs
1 parent cde34e1 commit 6473d6c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

security/user_checkers.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ displayed to the user::
2121
namespace App\Security;
2222

2323
use App\Entity\User as AppUser;
24+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
25+
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
2426
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
2527
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
2628
use Symfony\Component\Security\Core\User\UserCheckerInterface;
@@ -50,9 +52,17 @@ displayed to the user::
5052
if ($user->isExpired()) {
5153
throw new AccountExpiredException('...');
5254
}
55+
56+
if (!\in_array('foo', $token->getRoleNames())) {
57+
throw new AccessDeniedException('...');
58+
}
5359
}
5460
}
5561

62+
.. versionadded:: 7.2
63+
64+
The ``token`` argument for the ``checkPostAuth()`` method was introduced in Symfony 7.2.
65+
5666
Enabling the Custom User Checker
5767
--------------------------------
5868

0 commit comments

Comments
 (0)