diff --git a/apps/users/constans.py b/apps/users/constans.py index eb14c7e..89c0e3c 100644 --- a/apps/users/constans.py +++ b/apps/users/constans.py @@ -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') diff --git a/apps/users/models.py b/apps/users/models.py index 2ee813c..268f314 100644 --- a/apps/users/models.py +++ b/apps/users/models.py @@ -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)