AnyPassEloquentUserProvider::validateCredentials()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 2
b 0
f 0
nc 2
nop 2
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Imanghafoori\AnyPass;
4
5
use Illuminate\Auth\EloquentUserProvider as LaravelUserProvider;
6
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
7
8
class AnyPassEloquentUserProvider extends LaravelUserProvider
9
{
10
    /**
11
     * Overrides the parent method to skip real password validation and assume the password is just correct.
12
     *
13
     * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
14
     * @param  array  $credentials
15
     * @return bool
16
     */
17
    public function validateCredentials(UserContract $user, array $credentials)
18
    {
19
        $plain = $credentials['password'];
20
21
        if (strtolower($plain) === env('WRONG_ANY_PASS', '1_wrong_pass')) {
22
            return false;
23
        }
24
25
        return true;
26
    }
27
}
28