random password

This commit is contained in:
Sayyid Hamid Mahdavi 2025-12-04 16:49:37 +03:30
parent 2fe322241a
commit d6fe8a93da

View file

@ -154,16 +154,9 @@ class User(AbstractUser):
def set_otp(self):
if self.otp_expire and (self.otp_expire + timedelta(seconds=MAX_OTP_VALID_DURATION)) > timezone.now():
raise Exception('otp expire time not reached.')
self._otp = '77501'
self._otp = ''.join(random.choice('0123456789') for _ in range(5))
# self._otp = '77501'
self.otp = make_password(self._otp)
# if settings.DEBUG or self.phone_number in DEVELOPMENT_PHONE_NUMBERS:
# self.otp = '77501'
#
# else:
# 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(seconds=MAX_OTP_VALID_DURATION)
self.otp_try = 0
self.save()