mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2025-07-22 05:29:46 +03:00
Merge 341a327840
into 42d039b473
This commit is contained in:
commit
5216f5affd
|
@ -25,7 +25,12 @@ class LoginSerializer(serializers.Serializer):
|
|||
user = None
|
||||
|
||||
if email and password:
|
||||
user = authenticate(email=email, password=password)
|
||||
try:
|
||||
username = UserModel.objects.get(email__iexact=email).get_username()
|
||||
user = authenticate(username=username, password=password)
|
||||
except UserModel.DoesNotExist:
|
||||
msg = _('Unable to log in with provided credentials.')
|
||||
raise exceptions.ValidationError(msg)
|
||||
else:
|
||||
msg = _('Must include "email" and "password".')
|
||||
raise exceptions.ValidationError(msg)
|
||||
|
@ -47,7 +52,12 @@ class LoginSerializer(serializers.Serializer):
|
|||
user = None
|
||||
|
||||
if email and password:
|
||||
user = authenticate(email=email, password=password)
|
||||
try:
|
||||
username = UserModel.objects.get(email__iexact=email).get_username()
|
||||
user = authenticate(username=username, password=password)
|
||||
except UserModel.DoesNotExist:
|
||||
msg = _('Unable to log in with provided credentials.')
|
||||
raise exceptions.ValidationError(msg)
|
||||
elif username and password:
|
||||
user = authenticate(username=username, password=password)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user