闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. class Auth::ConfirmationsController < Devise::ConfirmationsController
  3. layout 'auth'
  4. before_action :set_body_classes
  5. before_action :require_unconfirmed!
  6. skip_before_action :require_functional!
  7. def new
  8. super
  9. resource.email = current_user.unconfirmed_email || current_user.email if user_signed_in?
  10. end
  11. private
  12. def require_unconfirmed!
  13. if user_signed_in? && current_user.confirmed? && current_user.unconfirmed_email.blank?
  14. redirect_to(current_user.approved? ? root_path : edit_user_registration_path)
  15. end
  16. end
  17. def set_body_classes
  18. @body_classes = 'lighter'
  19. end
  20. def after_resending_confirmation_instructions_path_for(_resource_name)
  21. if user_signed_in?
  22. if current_user.confirmed? && current_user.approved?
  23. edit_user_registration_path
  24. else
  25. auth_setup_path
  26. end
  27. else
  28. new_user_session_path
  29. end
  30. end
  31. def after_confirmation_path_for(_resource_name, user)
  32. if user.created_by_application && truthy_param?(:redirect_to_app)
  33. user.created_by_application.redirect_uri
  34. else
  35. super
  36. end
  37. end
  38. end