Revert "Merge branch '629-cookie-auth' into 'develop'"

This reverts commit 8b47af8b81, reversing
changes made to c0055b3b20.
This commit is contained in:
Eliot Berriot 2019-03-15 15:52:30 +01:00
parent 666409dce0
commit b9f0c6aecd
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
18 changed files with 153 additions and 203 deletions

View file

@ -1,22 +1,17 @@
from asgiref.sync import async_to_sync
from channels.generic.websocket import JsonWebsocketConsumer
from channels import auth
from funkwhale_api.common import channels
class JsonAuthConsumer(JsonWebsocketConsumer):
def connect(self):
if "user" not in self.scope:
try:
self.scope["user"] = async_to_sync(auth.get_user)(self.scope)
except (ValueError, AssertionError, AttributeError, KeyError):
return self.close()
if self.scope["user"] and self.scope["user"].is_authenticated:
return self.accept()
else:
try:
assert self.scope["user"].pk is not None
except (AssertionError, AttributeError, KeyError):
return self.close()
return self.accept()
def accept(self):
super().accept()
for group in self.groups: