mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'bug/API_Users' into 'dev'
Fix bug where any user could see all stats See merge request crafty-controller/crafty-commander!242
This commit is contained in:
commit
bb66b85b9d
@ -95,9 +95,15 @@ class ServersStats(ApiHandler):
|
|||||||
def get(self):
|
def get(self):
|
||||||
"""Get details about all servers"""
|
"""Get details about all servers"""
|
||||||
authenticated = self.authenticate_user()
|
authenticated = self.authenticate_user()
|
||||||
|
user_obj = self.controller.users.get_user_by_api_token(self.api_token)
|
||||||
if not authenticated:
|
if not authenticated:
|
||||||
return
|
return
|
||||||
|
if user_obj["superuser"]:
|
||||||
raw_stats = self.controller.servers.get_all_servers_stats()
|
raw_stats = self.controller.servers.get_all_servers_stats()
|
||||||
|
else:
|
||||||
|
raw_stats = self.controller.servers.get_authorized_servers_stats(
|
||||||
|
user_obj["user_id"]
|
||||||
|
)
|
||||||
stats = []
|
stats = []
|
||||||
for rs in raw_stats:
|
for rs in raw_stats:
|
||||||
s = {}
|
s = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user