Overview

Namespaces

  • PHP
  • ProgrammingAreHard
    • Arbiter
      • Domain
      • Model
  • Symfony
    • Component
      • Security
        • Acl
          • Exception
          • Model
          • Permission
        • Core
          • User

Classes

  • ChainUserProvider
  • InMemoryUserProvider
  • User
  • UserChecker

Interfaces

  • AdvancedUserInterface
  • EquatableInterface
  • UserCheckerInterface
  • UserInterface
  • UserProviderInterface
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /*
 4:  * This file is part of the Symfony package.
 5:  *
 6:  * (c) Fabien Potencier <fabien@symfony.com>
 7:  *
 8:  * For the full copyright and license information, please view the LICENSE
 9:  * file that was distributed with this source code.
10:  */
11: 
12: namespace Symfony\Component\Security\Core\User;
13: 
14: use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
15: use Symfony\Component\Security\Core\Exception\LockedException;
16: use Symfony\Component\Security\Core\Exception\DisabledException;
17: use Symfony\Component\Security\Core\Exception\AccountExpiredException;
18: 
19: /**
20:  * UserChecker checks the user account flags.
21:  *
22:  * @author Fabien Potencier <fabien@symfony.com>
23:  */
24: class UserChecker implements UserCheckerInterface
25: {
26:     /**
27:      * {@inheritdoc}
28:      */
29:     public function checkPreAuth(UserInterface $user)
30:     {
31:         if (!$user instanceof AdvancedUserInterface) {
32:             return;
33:         }
34: 
35:         if (!$user->isAccountNonLocked()) {
36:             $ex = new LockedException('User account is locked.');
37:             $ex->setUser($user);
38:             throw $ex;
39:         }
40: 
41:         if (!$user->isEnabled()) {
42:             $ex = new DisabledException('User account is disabled.');
43:             $ex->setUser($user);
44:             throw $ex;
45:         }
46: 
47:         if (!$user->isAccountNonExpired()) {
48:             $ex = new AccountExpiredException('User account has expired.');
49:             $ex->setUser($user);
50:             throw $ex;
51:         }
52:     }
53: 
54:     /**
55:      * {@inheritdoc}
56:      */
57:     public function checkPostAuth(UserInterface $user)
58:     {
59:         if (!$user instanceof AdvancedUserInterface) {
60:             return;
61:         }
62: 
63:         if (!$user->isCredentialsNonExpired()) {
64:             $ex = new CredentialsExpiredException('User credentials have expired.');
65:             $ex->setUser($user);
66:             throw $ex;
67:         }
68:     }
69: }
70: 
Arbiter API documentation generated by ApiGen 2.8.0