Guest User

Untitled

a guest
Apr 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. - form_tag change_password_users_path do
  2.  
  3. = error_messages_for :user, :header_message => "Please Try Again", :message => "We had some problems updating your account"
  4. %br
  5.  
  6. = label_tag :password, "New password:"
  7. = password_field_tag "password"
  8. %br
  9.  
  10. = label_tag :password_confirmation, "NConfirm new password:"
  11. = password_field_tag "password_confirmation"
  12. %br
  13.  
  14. = submit_tag "Update Account"
  15.  
  16. def change_password
  17. @user = current_user
  18. if request.post?
  19. @user.password = params[:password]
  20. @user.password_confirmation = params[:password_confirmation]
  21. if @user.save
  22. redirect_to user_path(current_user)
  23. else
  24. render :action => "change_password"
  25. end
  26. end
  27. end
  28.  
  29. def change_password
  30. @user = current_user
  31. if request.post?
  32. @user.password = params[:user][:password]
  33. @user.password_confirmation = params[:user][:password_confirmation]
  34. if @user.changed? && @user.save
  35. redirect_to user_path(current_user)
  36. else
  37. render :action => "change_password"
  38. end
  39. end
  40. end
  41.  
  42. @user.current_password = params[:user][:current_password]
  43. @user.password = params[:user][:password]
  44. @user.password_confiramtion = params[:user][:password_confirmation]
  45. if @user.save
  46. UserSession.create(:login => @user.login, :password => params[:user][:password])
  47. redirect_to user_path(current_user)
  48. else
  49. render :action => :change_password
  50. end
Add Comment
Please, Sign In to add comment