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.

ResetPasswordController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
c 1
b 0
f 1
dl 0
loc 53
ccs 0
cts 16
cp 0
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A resetPassword() 0 14 2
A broker() 0 3 1
A reset() 0 4 1
A credentials() 0 4 1
1
<?php
2
3
namespace App\Api\V1\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Support\Facades\Password;
7
use App\Api\V1\Requests\ResetPasswordRequest;
8
use Symfony\Component\HttpKernel\Exception\HttpException;
9
10
class ResetPasswordController extends Controller
11
{
12
    public function resetPassword(ResetPasswordRequest $request)
13
    {
14
        $response = $this->broker()->reset(
15
            $this->credentials($request), function ($user, $password) {
16
                $this->reset($user, $password);
17
            }
18
        );
19
20
        if (Password::PASSWORD_RESET !== $response) {
21
            throw new HttpException(500);
22
        }
23
24
        return response()->json([
25
            'status' => 'ok',
26
        ]);
27
    }
28
29
    /**
30
     * Get the broker to be used during password reset.
31
     *
32
     * @return \Illuminate\Contracts\Auth\PasswordBroker
33
     */
34
    public function broker()
35
    {
36
        return Password::broker();
37
    }
38
39
    /**
40
     * Get the password reset credentials from the request.
41
     *
42
     * @param ResetPasswordRequest $request
43
     *
44
     * @return array
45
     */
46
    protected function credentials(ResetPasswordRequest $request)
47
    {
48
        return $request->only(
49
            'email', 'password', 'password_confirmation', 'token'
50
        );
51
    }
52
53
    /**
54
     * Reset the given user's password.
55
     *
56
     * @param \Illuminate\Contracts\Auth\CanResetPassword $user
57
     * @param string                                      $password
58
     */
59
    protected function reset($user, $password)
60
    {
61
        $user->password = $password;
0 ignored issues
show
Bug introduced by
Accessing password on the interface Illuminate\Contracts\Auth\CanResetPassword suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
62
        $user->save();
63
    }
64
}
65