Guest User

Untitled

a guest
Jan 16th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. <form method="POST" action="{{ route('Agent.ChangePass') }}">
  2. <input type="hidden" value="{{ csrf_token() }}">
  3. <div class="col-sm-12 col-md-12">
  4. <div class="col-sm-12 col-md-12">
  5. <div class="form-group form-group-sm">
  6. <label>Old Password: </label>
  7. <input type="password" class="form-control" name="old_pass" required>
  8. </div>
  9. </div>
  10. <div class="col-sm-12 col-md-12">
  11. <div class="form-group form-group-sm">
  12. <label>New Password: </label>
  13. <input type="password" class="form-control" name="new_pass" required>
  14. </div>
  15. </div>
  16. <div class="col-sm-12 col-md-12">
  17. <div class="form-group form-group-sm">
  18. <label>Re-enter New Password: </label>
  19. <input type="password" class="form-control" name="confirm_pass" required>
  20. </div>
  21. <input type="submit" class="btn btn-info btn-sm" value="Save"/>
  22.  
  23. </div>
  24. </div>
  25. </form>
  26.  
  27. Route::post('Agent/ChangePass', 'AgentsController@changePass')->name('Agent.ChangePass');
  28.  
  29. public function changePass(Request $request){
  30. dd($request);
  31. if (!(Hash::check($request->get('old_pass'), Auth::user()->password))) {
  32. // The passwords matches
  33. return redirect()->back()->with("error","Your current password does not matches with the password you provided. Please try again.");
  34. }
  35.  
  36. if(strcmp($request->get('confirm_pass'), $request->get('new_pass')) != 0){
  37. //Current password and new password are same
  38. return redirect()->back()->with("error","Your new password does not match your re-entered password.");
  39. }
  40.  
  41. //Change Password
  42. $user = Auth::user()->id;
  43. $users = Agent::find($users);
  44. $users->password = bcrypt($request->get('new_pass'));
  45. $users->save();
  46.  
  47. return redirect()->back()->with("success","Password changed successfully !");
  48. }
  49.  
  50. Route::post('Agent/ChangePass', ['uses' => 'AgentsController@changePass'])->name('Agent.ChangePass');
  51.  
  52. action="{{ url('Agent/ChangePass') }}"
Add Comment
Please, Sign In to add comment