Guest User

Untitled

a guest
Mar 31st, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. - the introduced actual password should be equal to the actual password of the user (users table has a column "password" on db)
  2. - the new_password and new_password_confirm should be equal
  3. - the actual_password and new_password should be different
  4.  
  5. public function updatePassword(Request $request){
  6. $this->validate($request, [
  7. 'actual_password' => 'required|string|min:6|confirmed',
  8. 'new_password' => 'required|string|min:6',
  9. 'new_password_confirm' => 'required|string|min:6|same:new_password',
  10. ]);
  11.  
  12. $user = Auth::user();
  13. $user->password = bcrypt($request->new_password);
  14. $user->save();
  15.  
  16. Session::flash('success', 'updated.');
  17.  
  18. return redirect()->back();
  19. }
  20.  
  21. <form method="post" action="{{route('user.updatePassword')}}" class="clearfix">
  22. {{csrf_field()}}
  23. <div>
  24. <label>New Password</label>
  25. <input type="password" class="form-control" name="actual_password" id="actual_password" placeholder="">
  26. </div>
  27. <div>
  28. <label for="new_password">New Password</label>
  29. <input type="password" class="form-control" name="new_password" id="new_password" placeholder="">
  30. </div>
  31. <div>
  32. <label>Confirm password</label>
  33. <input type="password" name="new_password_confirm" class="form-control" id="new_password_confirm" placeholder="">
  34. </div>
  35. <div class="form-group">
  36. <input type="submit" value="Update password"/>
  37. </div>
  38. </form>
Add Comment
Please, Sign In to add comment