Guest User

Untitled

a guest
Jun 5th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1.  
  2. ## start of form
  3. <%= error_messages_for 'user' %>
  4. <% form_for :user do |form| %>
  5.  
  6. ## Change password method
  7. def password
  8. @user = User.find(session[:user_id])
  9. return unless request.post?
  10. if User.authenticate(current_user.login, params[:old_password])
  11. if ((params[:password] == params[:password_confirmation]) &&
  12. !params[:password_confirmation].blank?)
  13. current_user.password_confirmation = params[:password_confirmation]
  14. current_user.password = params[:password]
  15.  
  16. if current_user.save
  17. flash.now[:notice] = "Password successfully updated"
  18. render :action => 'password'
  19. else
  20. flash.now[:error] = "Password not changed"
  21. end
  22.  
  23. else
  24. flash.now[:error] = "New Password mismatch"
  25. @old_password = params[:old_password]
  26. render :action => 'password'
  27. end
  28. else
  29. flash.now[:error] = "Old password incorrect"
  30. render :action => 'password'
  31. end
  32. end
Add Comment
Please, Sign In to add comment