Completed
Pull Request — master (#40)
by
unknown
02:05
created

ValidateCurrentPassword::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 3
1
<?php namespace Anomaly\UsersModule\User\Validation;
2
3
use Anomaly\UsersModule\User\Password\ChangePasswordFormBuilder;
4
use Anomaly\UsersModule\User\UserAuthenticator;
5
use Illuminate\Contracts\Auth\Guard;
6
7
/**
8
 * Class ValidateCredentials
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 */
14
class ValidateCurrentPassword
15
{
16
17
    /**
18
     * Handle the validation.
19
     *
20
     * @param  UserAuthenticator $authenticator
21
     * @param  ChangePasswordFormBuilder $builder
22
     * @return bool
23
     */
24
    public function handle(Guard $guard, UserAuthenticator $authenticator, ChangePasswordFormBuilder $builder)
25
    {
26
        $credentials = [
27
            'email' => $guard->user()->email,
28
            'password' => $builder->getFormValues()->get('password_old'),
29
        ];
30
31
        if (! $response = $authenticator->authenticate($credentials)) {
32
            return false;
33
        }
34
35
        return true;
36
    }
37
}
38