MAX_OTP_VALID_DURATION
This commit is contained in:
parent
cec077c3d9
commit
d3f83150f1
2 changed files with 5 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
|
||||
MAX_OTP_TRY = 3
|
||||
DEVELOPMENT_PHONE_NUMBERS = ['+989999999999', '+989999999998']
|
||||
MAX_OTP_VALID_DURATION = 120
|
||||
|
||||
class GenderChoices(models.TextChoices):
|
||||
MALE = "m", _('male')
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ from utils.clients.payam_sms import send_sms
|
|||
from .provinces_and_cities import state
|
||||
# from .tasks import send_notification
|
||||
|
||||
from apps.users.constans import MAX_OTP_TRY, DEVELOPMENT_PHONE_NUMBERS, GenderChoices, EducationDegreeChoices
|
||||
from apps.users.constans import MAX_OTP_TRY, DEVELOPMENT_PHONE_NUMBERS, GenderChoices, EducationDegreeChoices, \
|
||||
MAX_OTP_VALID_DURATION
|
||||
|
||||
|
||||
class UserManager(BaseUserManager):
|
||||
|
|
@ -157,13 +158,13 @@ class User(AbstractUser):
|
|||
# self.otp = ''.join(random.choice('0123456789') for _ in range(5))
|
||||
# self.otp = ''.join(random.choice('0123456789') for _ in range(5))
|
||||
|
||||
self.otp_expire = timezone.now() + timedelta(minutes=5)
|
||||
self.otp_expire = timezone.now() + timedelta(seconds=MAX_OTP_VALID_DURATION)
|
||||
self.otp_try = 0
|
||||
|
||||
def set_ott(self):
|
||||
self.ott = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(32))
|
||||
# self.ott = ''.join(random.choice(string.ascii_letters+string.digits+string.punctuation) for _ in range(32))
|
||||
self.ott_expire = timezone.now() + timedelta(seconds=300)
|
||||
self.ott_expire = timezone.now() + timedelta(seconds=MAX_OTP_VALID_DURATION)
|
||||
|
||||
def otp_is_valid(self):
|
||||
return bool(self.otp and timezone.now() <= self.otp_expire)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue