Guest User

Untitled

a guest
May 20th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. def update
  2. if params[:id].nil?
  3. render :action => 'new'
  4. return
  5. end
  6. if params[:password].blank?
  7. flash[:notice] = "Password field cannot be blank."
  8. render :action => 'edit', :id => params[:id]
  9. return
  10. end
  11. @user = User.find_by_password_reset_code(params[:id]) if params[:id]
  12. raise if @user.nil?
  13. return if @user unless params[:password]
  14. if(params[:password] == params[:password_confirmation])
  15. @user.password_confirmation = params[:password_confirmation]
  16. @user.password = params[:password]
  17. @user.reset_password
  18. flash[:notice] = @user.save ? "Password reset." : "Password not re-set."
  19. else
  20. flash[:notice] = "Password mismatch."
  21. render :action => 'edit', :id => params[:id]
  22. return
  23. end
  24. redirect_to login_path
  25. rescue
  26. logger.error "Invalid reset code entered"
  27. flash[:notice] = "Sorry - That is an invalid password reset \
  28. code.(Perhaps your email client inserted a carriage return?)"
  29. redirect_to new_user_path
  30. end
Add Comment
Please, Sign In to add comment