discourse/lib/homepage_constraint.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
467 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class HomePageConstraint
def initialize(filter)
@filter = filter
end
def matches?(request)
return @filter == 'finish_installation' if SiteSetting.has_login_hint?
provider = Discourse.current_user_provider.new(request.env)
homepage = provider&.current_user&.user_option&.homepage || SiteSetting.anonymous_homepage
homepage == @filter
rescue Discourse::InvalidAccess, Discourse::ReadOnly
false
end
end