From 9c6a7e94282d29be9129eb85f99bebe4fa3512d2 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 10 Sep 2020 13:31:54 +0300 Subject: [PATCH] Login: fix server error when trying to login to users without userinfo. --- django_etebase/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django_etebase/views.py b/django_etebase/views.py index 7a6ea7d..636287e 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -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'})