2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-05-02 02:22:27 -05:00
|
|
|
class StaffConstraint
|
2013-05-02 00:15:17 -05:00
|
|
|
|
|
|
|
def matches?(request)
|
2018-09-04 01:17:05 -05:00
|
|
|
provider = Discourse.current_user_provider.new(request.env)
|
2018-03-28 13:48:14 -05:00
|
|
|
provider.current_user &&
|
|
|
|
provider.current_user.staff? &&
|
|
|
|
custom_staff_check(request)
|
2019-01-20 23:49:08 -06:00
|
|
|
rescue Discourse::InvalidAccess, Discourse::ReadOnly
|
2017-08-10 04:27:01 -05:00
|
|
|
false
|
2013-05-02 00:15:17 -05:00
|
|
|
end
|
|
|
|
|
2018-03-28 13:48:14 -05:00
|
|
|
# Extensibility point: plugins can overwrite this to add additional checks
|
|
|
|
# if they require.
|
|
|
|
def custom_staff_check(request)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2013-05-02 00:15:17 -05:00
|
|
|
end
|