Completed
Push — master ( 765e83...d9e173 )
by philippe
03:06
created

UserChecker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkPreAuth() 0 9 3
A checkPostAuth() 0 4 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: leazygomalas
5
 * Date: 19/02/2019
6
 * Time: 23:22
7
 */
8
9
namespace App\Security;
10
11
12
use App\Entity\User;
13
use Symfony\Component\Security\Core\Exception\AccountStatusException;
14
use Symfony\Component\Security\Core\Exception\DisabledException;
15
use Symfony\Component\Security\Core\User\UserCheckerInterface;
16
use Symfony\Component\Security\Core\User\UserInterface;
17
18
class UserChecker implements UserCheckerInterface
19
{
20
21
    /**
22
     * Checks the user account before authentication.
23
     *
24
     * @throws AccountStatusException
25
     */
26
    public function checkPreAuth(UserInterface $user)
27
    {
28
        if (!$user instanceof User) {
29
            return;
30
        }
31
        // user is deleted, show a generic Account Not Found message.
32
        if (!$user->getValidation()) {
33
            // or to customize the message shown
34
            throw new DisabledException();
35
            /*throw new CustomUserMessageAuthenticationException(
36
                'Your account was disabled. Sorry about that!'
37
            );*/
38
        }
39
    }
40
41
    /**
42
     * Checks the user account after authentication.
43
     *
44
     * @throws AccountStatusException
45
     */
46
    public function checkPostAuth(UserInterface $user)
47
    {
48
        if (!$user instanceof User) {
49
            return;
50
        }
51
    }
52
}