0
我使用django channels。我定义了一个JsonWebsocketConsumer
:如何仅允许特定用户连接到Django频道中的WebsocketConsumer?
class Consumer(JsonWebsocketConsumer):
http_user = True
def connect(self, message, **kwargs):
if not message.user.is_superuser:
self.disconnect(message, **kwargs)
但这不起作用。任何用户都可以连接并发送方法将要处理的数据。
我该如何只允许特定用户连接?