home_controller.rb 811 B

123456789101112131415161718192021222324252627282930313233
  1. # frozen_string_literal: true
  2. class HomeController < ApplicationController
  3. before_action :redirect_unauthenticated_to_permalinks!
  4. before_action :authenticate_user!
  5. before_action :set_referrer_policy_header
  6. def index
  7. @body_classes = 'app-body'
  8. end
  9. private
  10. def redirect_unauthenticated_to_permalinks!
  11. return if user_signed_in?
  12. redirect_to(PermalinkRedirector.new(request.path).redirect_path || default_redirect_path)
  13. end
  14. def default_redirect_path
  15. if request.path.start_with?('/web') || whitelist_mode?
  16. new_user_session_path
  17. elsif single_user_mode?
  18. short_account_path(Account.local.without_suspended.where('id > 0').first)
  19. else
  20. about_path
  21. end
  22. end
  23. def set_referrer_policy_header
  24. response.headers['Referrer-Policy'] = 'origin'
  25. end
  26. end