Add extensibility to admin constraints

This commit is contained in:
Robin Ward 2018-01-25 13:56:08 -05:00
parent 7b4e6d508b
commit feec968801
1 changed files with 9 additions and 1 deletions

View File

@ -9,9 +9,17 @@ class AdminConstraint
def matches?(request)
return false if @require_master && RailsMultisite::ConnectionManagement.current_db != "default"
provider = Discourse.current_user_provider.new(request.env)
provider.current_user && provider.current_user.admin?
provider.current_user &&
provider.current_user.admin? &&
custom_admin_check(request)
rescue Discourse::InvalidAccess
false
end
# Extensibility point: plugins can overwrite this to add additional checks
# if they require.
def custom_admin_check(request)
true
end
end