confirmations_controller.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.confirmation_redirect_uri
  34. else
  35. super
  36. end
  37. end
  38. end