Passed
Push — task/log-forgot-password-reque... ( 482660 )
by
unknown
06:40
created

ForgotPasswordController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
6
use Illuminate\Support\Facades\Lang;
7
use Illuminate\Support\Facades\Log;
8
use Illuminate\Http\Request;
9
use App\Http\Controllers\Auth\AuthController;
10
use App\Models\User;
11
use Jenssegers\Date\Date;
12
13
class ForgotPasswordController extends AuthController
14
{
15
    /*
16
    |--------------------------------------------------------------------------
17
    | Password Reset Controller
18
    |--------------------------------------------------------------------------
19
    |
20
    | This controller is responsible for handling password reset emails and
21
    | includes a trait which assists in sending these notifications from
22
    | your application to your users. Feel free to explore this trait.
23
    |
24
    */
25
26
    use SendsPasswordResetEmails {
27
        sendResetLinkEmail as protected sendResetLinkEmailOverridden;
28
    }
29
30
    /**
31
     * Create a new controller instance.
32
     *
33
     * @return void
34
     */
35
    public function __construct()
36
    {
37
        $this->middleware('guest');
38
    }
39
40
    /**
41
     * OVERRIDE
42
     *
43
     * Display the form to request a password reset link.
44
     *
45
     * @return \Illuminate\Http\Response
46
     */
47
    public function showLinkRequestForm()
48
    {
49
        return view('auth.passwords.email', [
0 ignored issues
show
Bug introduced by
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

49
        return /** @scrutinizer ignore-call */ view('auth.passwords.email', [
Loading history...
50
            'routes' => $this->auth_routes(),
51
            'forgot_password' => Lang::get('common/auth/forgot_password'),
52
        ]);
53
    }
54
55
    /**
56
     * Log information for reset password request.
57
     *
58
     * @param  \Illuminate\Http\Request  $request
59
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
60
     */
61
    public function sendResetLinkEmail(Request $request) {
62
        if( User::where('email', $request->input('email'))->exists() ){ // Check if user exists.
63
            Log::notice('Reset Password email requested by ' . $request->input('email') . ' at ' . Date::now()->format('c'));
64
        }
65
        return $this->sendResetLinkEmailOverridden($request);
66
    }
67
}
68