ChangePasswordController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
c 0
b 0
f 0
dl 0
loc 19
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A changePassword() 0 7 1
A __construct() 0 3 1
1
<?php
2
3
namespace MedianetDev\LaravelAuthApi\Http\Controllers;
4
5
use Illuminate\Support\Facades\Auth;
6
use Illuminate\Support\Facades\Hash;
7
use MedianetDev\LaravelAuthApi\Http\Helpers\ApiResponse;
8
use MedianetDev\LaravelAuthApi\Http\Requests\ChangePasswordRequest;
9
10
class ChangePasswordController extends Controller
11
{
12
    /**
13
     * Create a new controller instance.
14
     *
15
     * @return void
16
     */
17
    public function __construct()
18
    {
19
        $this->middleware('auth:api');
20
    }
21
22
    public function changePassword(ChangePasswordRequest $request)
23
    {
24
        $user = Auth::guard('apiauth')->user();
25
        $user->password = Hash::make($request->new_password);
0 ignored issues
show
Bug introduced by
Accessing password on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
26
        $user->save();
27
28
        return ApiResponse::send(['status' => 'Password changed successfully'], 1, 200, 'Password changed successfully');
29
    }
30
}
31