Fix auth
This commit is contained in:
parent
9463ef75e9
commit
bb69819278
@ -1,4 +1,5 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import FieldError, ValidationError
|
||||
from rest_framework import exceptions
|
||||
from rest_framework.authentication import BaseAuthentication
|
||||
|
||||
@ -20,9 +21,13 @@ class UuidAuthentication(BaseAuthentication):
|
||||
User = get_user_model()
|
||||
|
||||
try:
|
||||
user = User.object.get(uuid=payload)
|
||||
user = User.objects.get(uid=payload)
|
||||
except User.DoesNotExist:
|
||||
raise exceptions.AuthenticationFailed("Invalid user id")
|
||||
except FieldError:
|
||||
raise exceptions.AuthenticationFailed("Incorrect user model")
|
||||
except ValidationError:
|
||||
raise exceptions.AuthenticationFailed("Incorrect user id")
|
||||
|
||||
if not user.is_active:
|
||||
raise exceptions.AuthenticationFailed("User isn't active")
|
||||
|
Loading…
x
Reference in New Issue
Block a user