title: How to only allow logged in users connect to websocket in Django Channels?
body: <p>I have a chat app and I want only users that are logged in to be able to connect to the websocket.</p>
  
  <p>How can you achieve that?</p>
  
  <p>Is there something like the <code>@login_required</code> decorator for Django channels?</p>
  
  <p>I know from the documentation that that's how you can access the user:</p>
  
  <pre class="lang-py prettyprint-override"><code>class ChatConsumer(WebsocketConsumer):
  
      def connect(self, event):
          self.user = self.scope["user"]
  </code></pre>
  
  <p>But how do you deny the connection if the user isn't logged in?</p>