Add a way to fetch a user's pubkey.

master
Tom Hacohen 5 years ago
parent 47e1eec122
commit 40b7edcb84

@ -339,6 +339,14 @@ class UserQuerySerializer(serializers.ModelSerializer):
fields = (User.USERNAME_FIELD, User.EMAIL_FIELD) fields = (User.USERNAME_FIELD, User.EMAIL_FIELD)
class UserInfoPubkeySerializer(serializers.ModelSerializer):
pubkey = BinaryBase64Field()
class Meta:
model = models.UserInfo
fields = ('pubkey', )
class AuthenticationSignupSerializer(serializers.Serializer): class AuthenticationSignupSerializer(serializers.Serializer):
user = UserQuerySerializer(many=False) user = UserQuerySerializer(many=False)
salt = BinaryBase64Field() salt = BinaryBase64Field()

@ -34,7 +34,7 @@ import nacl.secret
import nacl.hash import nacl.hash
from . import app_settings, permissions from . import app_settings, permissions
from .models import Collection, CollectionItem, CollectionItemRevision, CollectionMember, CollectionInvitation from .models import Collection, CollectionItem, CollectionItemRevision, CollectionMember, CollectionInvitation, UserInfo
from .serializers import ( from .serializers import (
b64encode, b64encode,
AuthenticationSignupSerializer, AuthenticationSignupSerializer,
@ -50,6 +50,7 @@ from .serializers import (
CollectionMemberSerializer, CollectionMemberSerializer,
CollectionInvitationSerializer, CollectionInvitationSerializer,
InvitationAcceptSerializer, InvitationAcceptSerializer,
UserInfoPubkeySerializer,
UserSerializer, UserSerializer,
) )
@ -456,6 +457,14 @@ class CollectionInvitationViewSet(BaseViewSet):
return queryset.filter(fromMember__collection=collection) return queryset.filter(fromMember__collection=collection)
@action_decorator(detail=False, allowed_methods=['GET'], methods=['GET'])
def fetch_user_profile(self, request, collection_uid=None):
username = request.GET.get('username')
kwargs = {'owner__' + User.USERNAME_FIELD: username}
user_info = get_object_or_404(UserInfo.objects.all(), **kwargs)
serializer = UserInfoPubkeySerializer(user_info)
return Response(serializer.data)
class InvitationIncomingViewSet(BaseViewSet): class InvitationIncomingViewSet(BaseViewSet):
allowed_methods = ['GET', 'DELETE'] allowed_methods = ['GET', 'DELETE']

Loading…
Cancel
Save