2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-28 21:01:13 +08:00
|
|
|
class HomePageConstraint
|
|
|
|
def initialize(filter)
|
|
|
|
@filter = filter
|
|
|
|
end
|
|
|
|
|
|
|
|
def matches?(request)
|
2016-10-18 23:44:25 +08:00
|
|
|
return @filter == 'finish_installation' if SiteSetting.has_login_hint?
|
|
|
|
|
2013-10-09 12:10:37 +08:00
|
|
|
provider = Discourse.current_user_provider.new(request.env)
|
2017-11-10 03:45:19 +08:00
|
|
|
homepage = provider&.current_user&.user_option&.homepage || SiteSetting.anonymous_homepage
|
2013-03-28 21:01:13 +08:00
|
|
|
homepage == @filter
|
2019-01-21 13:49:08 +08:00
|
|
|
rescue Discourse::InvalidAccess, Discourse::ReadOnly
|
2017-01-06 13:18:04 +08:00
|
|
|
false
|
2013-03-28 21:01:13 +08:00
|
|
|
end
|
2013-10-09 12:10:37 +08:00
|
|
|
end
|