Passed
Pull Request — master (#89)
by
unknown
40:26
created

ResetPasswordController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Support\Facades\Log;
7
use App\Http\Controllers\Controller;
8
use Illuminate\Auth\Events\PasswordReset;
9
use Illuminate\Foundation\Auth\ResetsPasswords;
10
11
class ResetPasswordController extends Controller
12
{
13
    /*
14
    |--------------------------------------------------------------------------
15
    | Password Reset Controller
16
    |--------------------------------------------------------------------------
17
    |
18
    | This controller is responsible for handling password reset requests
19
    | and uses a simple trait to include this behavior. You're free to
20
    | explore this trait and override any methods you wish to tweak.
21
    |
22
    */
23
24
    use ResetsPasswords;
25
26
    /**
27
     * Where to redirect users after resetting their password.
28
     *
29
     * @var string
30
     */
31
    protected $redirectTo = '/dashboard';
32
    protected $email;
33
34
    /**
35
     * Create a new controller instance.
36
     *
37
     * @return void
38
     */
39 12
    public function __construct()
40
    {
41 12
        $this->middleware('guest');
42 12
        $this->email = '[email protected]';
43 12
    }
44
45 2
    protected function resetPassword($user, $password)
46
    {
47 2
        Log::info('User ID - '.$user->user_id.' '.$user->first_name.' '.$user->last_name.' has updated their password.');
48
49 2
        $this->setUserPassword($user, $password);
50 2
        $user->setRememberToken(Str::random(60));
51 2
        $user->save();
52
53 2
        event(new PasswordReset($user));
54 2
        $this->guard()->login($user);
55 2
    }
56
}
57