Add logic for phone (without '+' or '+7')
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from django.db import models
|
||||
from account.models import SiteUser
|
||||
from account.models import SiteUser, SiteAccountManager
|
||||
|
||||
from hashlib import sha512
|
||||
from django.contrib.auth.hashers import check_password
|
||||
@@ -25,15 +25,15 @@ class UserToken(models.Model):
|
||||
|
||||
@staticmethod
|
||||
def auth(login: str, password: str):
|
||||
user = SiteUser.objects.filter(email=login)
|
||||
|
||||
if len(user) == 0:
|
||||
try:
|
||||
user = SiteUser.get_by_natural_key(login)
|
||||
except Exception:
|
||||
raise Exception(API_ERROR_INVALID_LOGIN)
|
||||
|
||||
if not check_password(password, user[0].password):
|
||||
if not check_password(password, user.password):
|
||||
raise Exception(API_ERROR_INVALID_PASSWORD)
|
||||
|
||||
return user[0]
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
def deauth(token: str):
|
||||
|
Reference in New Issue
Block a user