File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 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::
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+ 
5666Enabling the Custom User Checker
5767-------------------------------- 
5868
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments