闭社主体 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.

46 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. redirect_to edit_user_registration_path if user_signed_in? && current_user.confirmed? && current_user.unconfirmed_email.blank?
  14. end
  15. def set_body_classes
  16. @body_classes = 'lighter'
  17. end
  18. def after_resending_confirmation_instructions_path_for(_resource_name)
  19. if user_signed_in?
  20. if current_user.confirmed? && current_user.approved?
  21. edit_user_registration_path
  22. else
  23. auth_setup_path
  24. end
  25. else
  26. new_user_session_path
  27. end
  28. end
  29. def after_confirmation_path_for(_resource_name, user)
  30. if user.created_by_application && truthy_param?(:redirect_to_app)
  31. user.created_by_application.redirect_uri
  32. else
  33. super
  34. end
  35. end
  36. end