1
0
mirror of https://github.com/etesync/server synced 2024-12-27 09:48:24 +00:00

Login: fix server error when trying to login to users without userinfo.

This commit is contained in:
Tom Hacohen 2020-09-10 13:31:54 +03:00
parent a85e816810
commit 9c6a7e9428

View File

@ -656,7 +656,10 @@ class AuthenticationViewSet(viewsets.ViewSet):
def get_login_user(self, username):
kwargs = {User.USERNAME_FIELD: username.lower()}
try:
return self.get_queryset().get(**kwargs)
user = self.get_queryset().get(**kwargs)
if not hasattr(user, 'userinfo'):
raise AuthenticationFailed({'code': 'user_not_init', 'detail': 'User not properly init'})
return user
except User.DoesNotExist:
raise AuthenticationFailed({'code': 'user_not_found', 'detail': 'User not found'})