File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ displayed to the user::
21
21
namespace App\Security;
22
22
23
23
use App\Entity\User as AppUser;
24
+ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
25
+ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
24
26
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
25
27
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
26
28
use Symfony\Component\Security\Core\User\UserCheckerInterface;
@@ -50,9 +52,17 @@ displayed to the user::
50
52
if ($user->isExpired()) {
51
53
throw new AccountExpiredException('...');
52
54
}
55
+
56
+ if (!\in_array('foo', $token->getRoleNames())) {
57
+ throw new AccessDeniedException('...');
58
+ }
53
59
}
54
60
}
55
61
62
+ .. versionadded :: 7.2
63
+
64
+ The ``token `` argument for the ``checkPostAuth() `` method was introduced in Symfony 7.2.
65
+
56
66
Enabling the Custom User Checker
57
67
--------------------------------
58
68
You can’t perform that action at this time.
0 commit comments