2019-05-03 08:17:27 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2013-05-02 17:22:27 +10:00
|
|
|
class StaffConstraint
|
2013-05-02 15:15:17 +10:00
|
|
|
|
|
|
|
|
def matches?(request)
|
2021-11-17 23:27:30 +03:00
|
|
|
current_user = CurrentUser.lookup_from_env(request.env)
|
|
|
|
|
current_user&.staff? && custom_staff_check(request)
|
2019-01-21 13:49:08 +08:00
|
|
|
rescue Discourse::InvalidAccess, Discourse::ReadOnly
|
2017-08-10 18:27:01 +09:00
|
|
|
false
|
2013-05-02 15:15:17 +10: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 15:15:17 +10:00
|
|
|
end
|