fix: cache sms codes only after successful send
This commit is contained in:
parent
f17d9aec5b
commit
6c8a029456
|
|
@ -186,8 +186,8 @@ class SendCode(CreateAPIView):
|
|||
phone = request.data['phone']
|
||||
code = rannum(6)
|
||||
is_ok, _ = send_sms(phone, 505, {'code': code})
|
||||
cache.set(phone, code, 60*5)
|
||||
if is_ok:
|
||||
cache.set(phone, code, 60*5)
|
||||
return Response()
|
||||
raise ParseError('短信发送失败,请确认手机号')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue