Skip to content
Snippets Groups Projects
Verified Commit 81e7f03f authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Now persist actors in database during auth

parent 657bd4b0
No related branches found
No related tags found
No related merge requests found
...@@ -255,8 +255,6 @@ class TestActor(SystemActor): ...@@ -255,8 +255,6 @@ class TestActor(SystemActor):
accept, accept,
to=[ac['actor']], to=[ac['actor']],
on_behalf_of=test_actor) on_behalf_of=test_actor)
# we persist the sender in database
sender.save()
models.Follow.objects.get_or_create( models.Follow.objects.get_or_create(
actor=sender, actor=sender,
target=test_actor, target=test_actor,
......
...@@ -7,6 +7,7 @@ from rest_framework import exceptions ...@@ -7,6 +7,7 @@ from rest_framework import exceptions
from . import actors from . import actors
from . import keys from . import keys
from . import models
from . import serializers from . import serializers
from . import signing from . import signing
from . import utils from . import utils
...@@ -42,7 +43,10 @@ class SignatureAuthentication(authentication.BaseAuthentication): ...@@ -42,7 +43,10 @@ class SignatureAuthentication(authentication.BaseAuthentication):
except cryptography.exceptions.InvalidSignature: except cryptography.exceptions.InvalidSignature:
raise exceptions.AuthenticationFailed('Invalid signature') raise exceptions.AuthenticationFailed('Invalid signature')
return serializer.build() try:
return models.Actor.objects.get(url=actor_data['id'])
except models.Actor.DoesNotExist:
return serializer.save()
def authenticate(self, request): def authenticate(self, request):
setattr(request, 'actor', None) setattr(request, 'actor', None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment