fix(backend):AttributeError: 'AnonymousUser' object has no attribute 'get_channels_groups'

environments/review-docs-2433-weeqjg/deployments/21276
Petitminion 2025-06-04 02:36:11 +02:00 zatwierdzone przez petitminion
rodzic 724d85a2d9
commit 34203afe44
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -19,6 +19,10 @@ class JsonAuthConsumer(JsonWebsocketConsumer):
channels.group_add(group, self.channel_name)
def disconnect(self, close_code):
groups = self.scope["user"].get_channels_groups() + self.groups
if self.scope.get("user", False) and self.scope.get("user").pk is not None:
groups = self.scope["user"].get_channels_groups() + self.groups
else:
groups = self.groups
for group in groups:
channels.group_discard(group, self.channel_name)