From 82077a3ae1d5f20a99e83d1ccf19d683ed3af71e Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 14 Jan 2021 10:10:10 +0800 Subject: [PATCH] fix: bug --- apps/authentication/api/auth.py | 9 --------- apps/ops/ws.py | 6 +++++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/apps/authentication/api/auth.py b/apps/authentication/api/auth.py index cc77058ee..310aa3d4a 100644 --- a/apps/authentication/api/auth.py +++ b/apps/authentication/api/auth.py @@ -54,12 +54,3 @@ class UserConnectionTokenApi(RootOrgViewMixin, APIView): return Response(value) else: return Response({'user': value['user']}) - - def get_permissions(self): - if self.request.query_params.get('user-only', None): - self.permission_classes = (AllowAny,) - return super().get_permissions() - - - - diff --git a/apps/ops/ws.py b/apps/ops/ws.py index 343a6a8ee..67e12456a 100644 --- a/apps/ops/ws.py +++ b/apps/ops/ws.py @@ -15,7 +15,11 @@ class CeleryLogWebsocket(JsonWebsocketConsumer): disconnected = False def connect(self): - self.accept() + user = self.scope["user"] + if user.is_authenticated and user.is_org_admin: + self.accept() + else: + self.close() def receive(self, text_data=None, bytes_data=None, **kwargs): data = json.loads(text_data) -- GitLab