web_app_controller_concern.rb 630 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. module WebAppControllerConcern
  3. extend ActiveSupport::Concern
  4. included do
  5. before_action :redirect_unauthenticated_to_permalinks!
  6. before_action :set_app_body_class
  7. before_action :set_referrer_policy_header
  8. end
  9. def set_app_body_class
  10. @body_classes = 'app-body'
  11. end
  12. def set_referrer_policy_header
  13. response.headers['Referrer-Policy'] = 'origin'
  14. end
  15. def redirect_unauthenticated_to_permalinks!
  16. return if user_signed_in?
  17. redirect_path = PermalinkRedirector.new(request.path).redirect_path
  18. redirect_to(redirect_path) if redirect_path.present?
  19. end
  20. end