| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 37 | 5 | public function changePassword(Request $request) |
|
| 38 | { |
||
| 39 | 5 | $this->validate($request, [ |
|
| 40 | 5 | 'current_password' => 'required', |
|
| 41 | 'password' => 'required|confirmed|min:6', |
||
| 42 | ]); |
||
| 43 | |||
| 44 | 2 | if (! Hash::check($request->current_password, Auth::user()->password)) { |
|
| 45 | 1 | return response()->json( |
|
| 46 | 1 | ['current_password' => ['The current password you provided is incorrect.']], 422 |
|
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 50 | 1 | Auth::user()->password = Hash::make($request->password); |
|
| 51 | |||
| 52 | 1 | Auth::user()->save(); |
|
| 53 | 1 | } |
|
| 54 | } |
||
| 55 |