Passed
Push — develop ( 4cbaa0...09ba9e )
by Ngoding
05:32
created

PasswordResetLinkController::store()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 17
ccs 7
cts 8
cp 0.875
crap 2.0078
rs 10
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Http\Request;
7
use Illuminate\Support\Facades\Password;
8
9
class PasswordResetLinkController extends Controller
10
{
11
    /**
12
     * Display the password reset link request view.
13
     *
14
     * @return \Illuminate\View\View
15
     */
16 1
    public function create()
17
    {
18 1
        return view('auth.forgot-password');
19
    }
20
21
    /**
22
     * Handle an incoming password reset link request.
23
     *
24
     * @param  \Illuminate\Http\Request  $request
25
     * @return \Illuminate\Http\RedirectResponse
26
     *
27
     * @throws \Illuminate\Validation\ValidationException
28
     */
29 3
    public function store(Request $request)
30
    {
31 3
        $request->validate([
32
            'email' => ['required', 'email'],
33
        ]);
34
35
        // We will send the password reset link to this user. Once we have attempted
36
        // to send the link, we will examine the response then see the message we
37
        // need to show to the user. Finally, we'll send out a proper response.
38 3
        $status = Password::sendResetLink(
39 3
            $request->only('email')
40
        );
41
42 3
        return $status == Password::RESET_LINK_SENT
43 3
            ? back()->with('status', __($status))
44
            : back()->withInput($request->only('email'))
45 3
                    ->withErrors(['email' => __($status)]);
46
    }
47
}
48