discourse/lib/staff_constraint.rb

22 lines
470 B
Ruby
Raw Normal View History

require_dependency 'current_user'
class StaffConstraint
def matches?(request)
provider = Discourse.current_user_provider.new(request.env, rate_limit: false)
2018-03-29 02:48:14 +08:00
provider.current_user &&
provider.current_user.staff? &&
custom_staff_check(request)
rescue Discourse::InvalidAccess
false
end
2018-03-29 02:48:14 +08:00
# Extensibility point: plugins can overwrite this to add additional checks
# if they require.
def custom_staff_check(request)
true
end
end