GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

UserController::password()   B
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 16
nc 2
nop 1
dl 0
loc 24
rs 8.9713
c 1
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Http\Controllers\Controller;
6
use Auth;
7
use Hash;
8
use Illuminate\Http\Request;
9
use Validator;
10
11
class UserController extends Controller
12
{
13
    public function show()
14
    {
15
        $user = Auth::user();
16
17
        return view('user.show', compact('user'));
18
    }
19
20
    public function password(Request $request)
21
    {
22
        $validator = Validator::make($request->all(), [
23
            'current_password'    => 'required',
24
            'new_password'        => 'required',
25
            'new_repeat_password' => 'required|same:new_password',
26
        ]);
27
28
        $user = Auth::user();
29
        $currentPassword = $user->password;
30
31
        $ensureCurrentPassword = $request->input('current_password');
32
        if ($validator->passes() && Hash::check($ensureCurrentPassword, $currentPassword)) {
33
            $user->password = Hash::make($request->input('new_password'));
34
            $user->save();
35
            session(['status' => __('mmex.updated')]);
36
37
            return view('user.show', compact('user'));
38
        } else {
39
            $validator->errors()->add('current_password', __('mmex.current-password-wrong'));
40
41
            return redirect()->back()->withErrors($validator);
42
        }
43
    }
44
}
45