confirmations_controller.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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