Guest User

Untitled

a guest
Mar 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. def change_password
  2.  
  3. @user = User.find(params[:id])
  4.  
  5. if request.post?
  6. if User.authenticate(@user.username,
  7. params[:password][:old_password]) == @user
  8. @user.password = params[:password][:new_password]
  9. @user.password_confirmation =
  10. params[:password][:new_password_confirmation]
  11. if @user.save
  12. flash[:notice] = 'Your password has been changed'
  13. redirect_to :action => 'edit_my_information'
  14. else
  15. flash[:error] = 'Unable to change your password'
  16. end
  17. else
  18. flash[:error] = 'Invalid password'
  19. end
  20. end
  21. end
Add Comment
Please, Sign In to add comment