ForgotPasswordController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A sendResetLinkResponse() 0 5 1
A sendResetLinkEmail() 0 14 2
A showLinkRequestForm() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Http\Controllers\Auth;
6
7
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
8
use Illuminate\Http\RedirectResponse;
9
use Illuminate\Support\Facades\Password;
10
use Illuminate\View\View;
11
use Xetaravel\Http\Controllers\Controller;
12
use Xetaravel\Http\Requests\Password\ResetRequest;
13
14
class ForgotPasswordController extends Controller
15
{
16
    /*
17
    |--------------------------------------------------------------------------
18
    | Password Reset Controller
19
    |--------------------------------------------------------------------------
20
    |
21
    | This controller is responsible for handling password reset emails and
22
    | includes a trait which assists in sending these notifications from
23
    | your application to your users. Feel free to explore this trait.
24
    |
25
    */
26
    use SendsPasswordResetEmails;
27
28
    /**
29
     * Create a new controller instance.
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
35
        $this->middleware('guest');
36
    }
37
38
    /**
39
     * Get the response for a successful password reset link.
40
     *
41
     * @return RedirectResponse
42
     */
43
    protected function sendResetLinkResponse(): RedirectResponse
44
    {
45
        return redirect()
46
            ->route('auth.login')
0 ignored issues
show
Bug introduced by
The method route() does not exist on Illuminate\Routing\Redirector. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
            ->/** @scrutinizer ignore-call */ route('auth.login')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
            ->success('We have e-mailed your password reset link!');
48
    }
49
50
    /**
51
     * Display the form to request a password reset link.
52
     *
53
     * @return View
54
     */
55
    public function showLinkRequestForm(): View
56
    {
57
        return view('Auth.passwords.email');
58
    }
59
60
    /**
61
     * Send a reset link to the given user.
62
     *
63
     * @param ResetRequest $request
64
     *
65
     * @return RedirectResponse
66
     */
67
    public function sendResetLinkEmail(ResetRequest $request): RedirectResponse
68
    {
69
        $request->validated();
70
71
        // We will send the password reset link to this user. Once we have attempted
72
        // to send the link, we will examine the response then see the message we
73
        // need to show to the user. Finally, we'll send out a proper response.
74
        $response = $this->broker()->sendResetLink(
75
            $this->credentials($request)
76
        );
77
78
        return $response === Password::RESET_LINK_SENT
79
                    ? $this->sendResetLinkResponse()
80
                    : $this->sendResetLinkFailedResponse($request, $response);
81
    }
82
}
83