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