Added method to SimpleApiPlugins to allow locking API to only admins
This commit is contained in:
1 parent
edd6acc012
commit
3f272b209d
2 files changed
+12
-1
No files matched your search
@@ -56,6 +56,9 @@ def pluginData(name):
|
||||
return make_response("More than one api provider registered for {name}, can't proceed".format(name=name), 500)
|
||||
|
||||
api_plugin = api_plugins[0]
|
||||
if api_plugin.is_api_adminonly() and not current_user.is_admin():
|
||||
return make_response("Forbidden", 403)
|
||||
|
||||
response = api_plugin.on_api_get(request)
|
||||
|
||||
if response is not None:
|
||||
@@ -80,6 +83,9 @@ def pluginCommand(name):
|
||||
if valid_commands is None:
|
||||
return make_response("Method not allowed", 405)
|
||||
|
||||
if api_plugin.is_api_adminonly() and not current_user.is_admin():
|
||||
return make_response("Forbidden", 403)
|
||||
|
||||
command, data, response = get_json_command_from_request(request, valid_commands)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
Reference in new issue
Block a user