管理后台生成记录创作记录修复操作显示BUG
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ CORS_ORIGINS=["*"]
|
||||
|
||||
# RESOURCE
|
||||
RESOURCE_SIGN_SECRET=EOTpDZsEgkaYWPxgtIedOO0lDlH1moTS2rnSIemjzmO3
|
||||
RESOURCE_SIGN_EXPIRE_SECONDS=30
|
||||
RESOURCE_SIGN_EXPIRE_SECONDS=86400
|
||||
RESOURCE_SIGN_ARG_EXPIRE=exp
|
||||
RESOURCE_SIGN_ARG_SIGNATURE=sign
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ async def send_sms_code(req: SmsSendRequest):
|
||||
_validate_captcha_token(req.captcha_token)
|
||||
|
||||
try:
|
||||
ok = await generate_and_send_sms(req.phone, req.scene.value)
|
||||
ok, code = await generate_and_send_sms(req.phone, req.scene.value)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@@ -48,7 +48,9 @@ async def send_sms_code(req: SmsSendRequest):
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail="短信发送失败,请稍后重试",
|
||||
)
|
||||
return SmsResponse(message="验证码已发送", success=True)
|
||||
|
||||
message = f"验证码已发送:{code}" if settings.SMS_MOCK else "验证码已发送"
|
||||
return SmsResponse(message=message, success=True)
|
||||
|
||||
|
||||
@router.post(
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
import random
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
from typing import Any, Tuple
|
||||
|
||||
from app.config import settings
|
||||
from app.utils.redis import get_redis
|
||||
@@ -156,14 +156,14 @@ async def store_sms_code(phone: str, code: str, scene: str = "login", ttl: int |
|
||||
_sms_code_store[key] = (code, time.time() + ttl_seconds)
|
||||
|
||||
|
||||
async def generate_and_send_sms(phone: str, scene: str = "login") -> bool:
|
||||
async def generate_and_send_sms(phone: str, scene: str = "login") -> Tuple[bool, str]:
|
||||
scene = _normalize_scene(scene)
|
||||
await _check_send_limit(phone, scene)
|
||||
code = _generate_code()
|
||||
ok = await send_sms(phone, code, scene)
|
||||
if ok:
|
||||
await store_sms_code(phone, code, scene)
|
||||
return ok
|
||||
return ok, code
|
||||
|
||||
|
||||
async def verify_sms_code(phone: str, code: str, scene: str = "login") -> bool:
|
||||
|
||||
Reference in New Issue
Block a user