Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function update(PasswordUpdateRequest $request) |
||
24 | { |
||
25 | $check = Hash::check($request->input('old_password'), auth()->user()->password); |
||
26 | |||
27 | if (! $check) { |
||
28 | return redirect()->back()->withErrors(['Your current password is incorrect!']); |
||
29 | } |
||
30 | |||
31 | $user = $request->user(); |
||
32 | $user->password = bcrypt($request->input('new_password')); |
||
33 | $user->save(); |
||
34 | |||
35 | if (env('NOTIFICATIONS') == true) { |
||
36 | Mail::to($user)->queue(new PasswordUpdated()); |
||
37 | } |
||
38 | |||
39 | notify()->flash('Password', 'success', [ |
||
40 | 'timer' => 2000, |
||
41 | 'text' => 'Successfully updated!', |
||
42 | ]); |
||
43 | |||
44 | return redirect()->back(); |
||
45 | } |
||
47 |