Browse Source

fix: 验证码逻辑错误

pull/7235/head
xinwen 3 years ago committed by 老广
parent
commit
d94c515cfc
  1. 11
      apps/common/sdk/sms/utils.py

11
apps/common/sdk/sms/utils.py

@ -37,12 +37,17 @@ class SendAndVerifySMSUtil:
self.code = ''
self.timeout = timeout or self.TIMEOUT
self.key_suffix = key_suffix or str(phone)
self.key = self.KEY_TMPL.format(key_suffix)
self.key = self.KEY_TMPL.format(self.key_suffix)
def gen_and_send(self):
"""
生成保存发送
"""
ttl = self.ttl()
if ttl > 0:
logger.error('Send sms too frequently, delay {}'.format(ttl))
raise CodeSendTooFrequently(ttl)
try:
code = self.generate()
self.send(code)
@ -62,10 +67,6 @@ class SendAndVerifySMSUtil:
"""
发送信息的方法如果有错误直接抛出 api 异常
"""
ttl = self.ttl()
if ttl > 0:
logger.error('Send sms too frequently, delay {}'.format(ttl))
raise CodeSendTooFrequently(ttl)
sms = SMS()
sms.send_verify_code(self.phone, code)
cache.set(self.key, self.code, self.timeout)

Loading…
Cancel
Save