| Total Complexity | 7 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | class UserChecker implements UserCheckerInterface |
||
| 22 | { |
||
| 23 | private bool $denyUnverifiedLogin; |
||
| 24 | |||
| 25 | public function __construct(bool $denyUnverifiedLogin) |
||
| 28 | } |
||
| 29 | |||
| 30 | public function checkPreAuth(UserInterface $user): void |
||
| 31 | { |
||
| 32 | if (!$user instanceof AbstractUser) { |
||
| 33 | return; |
||
| 34 | } |
||
| 35 | |||
| 36 | // user is deleted, show a generic Account Not Found message. |
||
| 37 | if (!$user->isEnabled()) { |
||
| 38 | throw new DisabledException('This user is currently disabled'); |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($this->denyUnverifiedLogin && !$user->isEmailAddressVerified()) { |
||
|
|
|||
| 42 | throw new DisabledException('Please verify your email address before logging in. If you did not receive a confirmation email please try resetting your password using the forgot password feature.'); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | public function checkPostAuth(UserInterface $user): void |
||
| 48 | } |
||
| 49 | } |
||
| 50 |
If an expression can have both
false, andnullas possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.