ForgotPasswordController::showLinkRequestForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use App\Mail\Auth\PasswordResetLink;
7
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
8
use Illuminate\Http\Request;
9
use Illuminate\Support\Facades\Mail;
10
use Illuminate\Support\Facades\Password;
11
12
class ForgotPasswordController extends Controller
13
{
14
    /*
15
    |--------------------------------------------------------------------------
16
    | Password Reset Controller
17
    |--------------------------------------------------------------------------
18
    |
19
    | This controller is responsible for handling password reset emails and
20
    | includes a trait which assists in sending these notifications from
21
    | your application to your users. Feel free to explore this trait.
22
    |
23
    */
24
25
    use SendsPasswordResetEmails;
26
27
    public function showLinkRequestForm()
28
    {
29
        return view('public.auth.passwords.email');
30
    }
31
32
    public function sendResetLinkEmail(Request $request)
33
    {
34
        $this->validateEmail($request);
35
36
        // We will send the password reset link to this user. Once we have attempted
37
        // to send the link, we will examine the response then see the message we
38
        // need to show to the user. Finally, we'll send out a proper response.
39
        $response = $this->broker()->sendResetLink(
40
            $this->credentials($request),
41
            function ($user, $token){
42
                Mail::to($user->email)
43
                    ->send(new PasswordResetLink($user, $token));
44
            }
45
        );
46
47
        return $response == Password::RESET_LINK_SENT
48
            ? $this->sendResetLinkResponse($request, $response)
49
            : $this->sendResetLinkFailedResponse($request, $response);
50
    }
51
}
52