AuthenticatesUsers   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BeyondCode\EmailConfirmation\Traits;
4
5
6
use Illuminate\Http\Request;
7
use Illuminate\Validation\ValidationException;
8
9
trait AuthenticatesUsers
10
{
11
    use \Illuminate\Foundation\Auth\AuthenticatesUsers {
12
        attemptLogin as baseAttemptLogin;
13
    }
14
15
    /**
16
     * Attempt to log the user into the application.
17
     *
18
     * @param  \Illuminate\Http\Request $request
19
     * @return bool
20
     * @throws ValidationException
21
     */
22
    protected function attemptLogin(Request $request)
23
    {
24
        if ($this->guard()->validate($this->credentials($request))) {
25
            $user = $this->guard()->getLastAttempted();
0 ignored issues
show
Bug introduced by
The method getLastAttempted() does not exist on Illuminate\Contracts\Auth\StatefulGuard. Did you maybe mean attempt()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
26
27
            if (! is_null($user->confirmed_at)) {
28
                return $this->baseAttemptLogin($request);
0 ignored issues
show
Bug introduced by
The method baseAttemptLogin() does not exist on BeyondCode\EmailConfirma...aits\AuthenticatesUsers. Did you maybe mean attemptLogin()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
29
            }
30
31
            session([
32
                'confirmation_user_id' => $user->getKey()
33
            ]);
34
35
            throw ValidationException::withMessages([
36
                'confirmation' => [
37
                    __('confirmation::confirmation.not_confirmed', [
38
                        'resend_link' => route('auth.resend_confirmation')
39
                    ])
40
                ]
41
            ]);
42
        }
43
        return false;
44
    }
45
}