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

PasswordResetLinkController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 37
ccs 9
cts 10
cp 0.9
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A store() 0 17 2
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