From 5b2040fda316f962bb39c82d57c0bd37ba85afc7 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 31 May 2020 16:05:19 +0300 Subject: [PATCH] Fix running with postgres: convert memoryview to bytes for nacl. --- django_etesync/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django_etesync/views.py b/django_etesync/views.py index dff1096..7864c6a 100644 --- a/django_etesync/views.py +++ b/django_etesync/views.py @@ -601,7 +601,7 @@ class AuthenticationViewSet(viewsets.ViewSet): if serializer.is_valid(): user = self.get_login_user(serializer) - salt = user.userinfo.salt + salt = bytes(user.userinfo.salt) enc_key = self.get_encryption_key(salt) box = nacl.secret.SecretBox(enc_key) @@ -637,7 +637,7 @@ class AuthenticationViewSet(viewsets.ViewSet): host = serializer.validated_data['host'] challenge = serializer.validated_data['challenge'] - salt = user.userinfo.salt + salt = bytes(user.userinfo.salt) enc_key = self.get_encryption_key(salt) box = nacl.secret.SecretBox(enc_key) @@ -654,7 +654,7 @@ class AuthenticationViewSet(viewsets.ViewSet): content = {'code': 'wrong_host', 'detail': detail} return Response(content, status=status.HTTP_400_BAD_REQUEST) - verify_key = nacl.signing.VerifyKey(user.userinfo.loginPubkey, encoder=nacl.encoding.RawEncoder) + verify_key = nacl.signing.VerifyKey(bytes(user.userinfo.loginPubkey), encoder=nacl.encoding.RawEncoder) verify_key.verify(response_raw, signature) data = self.login_response_data(user)