Passed
Pull Request — master (#89)
by
unknown
40:26
created

ForgotPasswordController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 23
ccs 12
cts 12
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendResetLinkEmail() 0 13 3
A __construct() 0 3 1
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Facades\Log;
7
use App\Http\Controllers\Controller;
8
use Illuminate\Support\Facades\Password;
9
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
10
11
class ForgotPasswordController extends Controller
12
{
13
    use SendsPasswordResetEmails;
14
15 10
    public function __construct()
16
    {
17 10
        $this->middleware('guest');
18 10
    }
19
20
    //  Override the sendResetLinkEmail function to provide logging when a reset request is made
21 6
    public function sendResetLinkEmail(Request $request)
22
    {
23 6
        $this->validateEmail($request);
24
25 4
        $response = $this->broker()->sendResetLink(
26 4
            $this->credentials($request)
27
        );
28
29 4
        $passOrFail = $response === 'passwords.sent' ? 'successful' : 'failed';
30 4
        Log::info('A password reset request was made for '.$request->email.'.  Response - '.$passOrFail);
31 4
        return $response == Password::RESET_LINK_SENT
32 2
                    ? $this->sendResetLinkResponse($request, $response)
33 4
                    : $this->sendResetLinkFailedResponse($request, $response);
34
    }
35
}
36