mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 04:23:37 +08:00
21 lines
614 B
Ruby
21 lines
614 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)
|
|
# ensures we resolve the theme id as early as possible
|
|
ThemeResolver.resolve_theme_id(request, Guardian.new(current_user), current_user)
|
|
|
|
homepage = current_user&.user_option&.homepage || HomepageHelper.resolve(request, current_user)
|
|
homepage == @filter
|
|
rescue Discourse::InvalidAccess, Discourse::ReadOnly
|
|
false
|
|
end
|
|
end
|