forked from beyondcode/laravel-confirm-email
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthenticatesUsers.php
45 lines (37 loc) · 1.16 KB
/
AuthenticatesUsers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace BeyondCode\EmailConfirmation\Traits;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
trait AuthenticatesUsers
{
use \Illuminate\Foundation\Auth\AuthenticatesUsers {
attemptLogin as baseAttemptLogin;
}
/**
* Attempt to log the user into the application.
*
* @param \Illuminate\Http\Request $request
* @return bool
* @throws ValidationException
*/
protected function attemptLogin(Request $request)
{
if ($this->guard()->validate($this->credentials($request))) {
$user = $this->guard()->getLastAttempted();
if (! is_null($user->confirmed_at)) {
return $this->baseAttemptLogin($request);
}
session([
'confirmation_user_id' => $user->getKey()
]);
throw ValidationException::withMessages([
'confirmation' => [
__('confirmation::confirmation.not_confirmed', [
'resend_link' => route('auth.resend_confirmation')
])
]
]);
}
return false;
}
}