I'm basically after a login_required/LoginRequiredMixin equivalent for django channels. The docs have an authentication section, which describes how to get a user, but it seems to miss the bit where you actually deny access to users who are not authenticated.
from channels.generic.websockets import JsonWebsocketConsumer
class MyConsumer(JsonWebsocketConsumer):
channel_session_user = True
def connection_groups(self, **kwargs):
return ["test"]
def connect(self, message, **kwargs):
print message.user # AnonymousUser
self.send({"accept": True}) # False here still accepts and sends a message
How should I be denying/dropping the connection if message.user.is_anonymous is true?