fix: cache sms codes only after successful send

This commit is contained in:
caoqianming 2026-03-19 22:00:28 +08:00
parent f17d9aec5b
commit 6c8a029456
1 changed files with 1 additions and 1 deletions

View File

@ -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('短信发送失败,请确认手机号')