Advertisement
arhamzul

Untitled

Apr 28th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // to process the above form
  2. public function updateUserPassword(Requests\ChangePasswordRequest $request)
  3. {
  4. $user = User::find(Auth::user()->id);
  5.  
  6. // make sure old password is genuine
  7. $genuine = Hash::check($request->old_password, $user->password);
  8. if ($genuine == false) {
  9. return Redirect::back()->withInput()->with('errorMessage', trans('notification.incorrectOldPassword'));
  10. }
  11.  
  12. $user->password = bcrypt($request->password);
  13.  
  14. try {
  15. $user->save();
  16. return Redirect::to('/user/profile')->with('successMessage', trans('notification.changePasswordSuccess'));
  17. } catch (\Exception $e) {
  18. return Redirect::back()->withInput()->with('errorMessage', trans('notification.changePasswordFail'));
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement