discourse/lib/homepage_constraint.rb
Penar Musaraj 1eb70973a2
DEV: allow themes to render their own custom homepage (#26291)
This PR adds a theme modifier and route so that custom themes can opt to show their own homepage. See PR description for example usage.
2024-04-02 11:05:08 -04:00

18 lines
468 B
Ruby

# frozen_string_literal: true
class HomePageConstraint
def initialize(filter)
@filter = filter
end
def matches?(request)
return @filter == "finish_installation" if SiteSetting.has_login_hint?
current_user = CurrentUser.lookup_from_env(request.env)
homepage = current_user&.user_option&.homepage || HomepageHelper.resolve(request, current_user)
homepage == @filter
rescue Discourse::InvalidAccess, Discourse::ReadOnly
false
end
end