This commit is contained in:
yumoqing 2026-03-18 14:09:28 +08:00
parent cfbe37f2b6
commit e0c7596444
2 changed files with 49 additions and 0 deletions

24
wwwroot/gen_sms_code.dspy Normal file
View File

@ -0,0 +1,24 @@
phone = params_kw.cellphone
if phone is None:
return {
"status": "error",
"data":{
"message": "没有收到手机号"
}
}
# 使用短信模块发布的sms_engine实例生成验证码参数手机号
status, timeout = await sms_engine.generate_sms_code(phone)
if not status:
return {
status": "error",
"data": {
message": f'为{phone}生成的手机号出错"
}
}
return {
"status": "ok",
"data": {
"message": “短信码已生成",
"timeout": timeout
}
}

25
wwwroot/phone_login.dspy Normal file
View File

@ -0,0 +1,25 @@
# 用短信模块检查验证码是否正确
if params_kw.cellphone:
return {
"status": "error",
"data":{
"message": "需输入手机号"
}
}
if params_kw.sms_code is None:
return {
"status": "error",
"data": {
"message": "需输入验证码"
}
}
f = await sms_engine.check_sms_code(params_kw.cellphone, params_kw.sms_code)
if not f:
return {
"status": "error",
"data": {
"message": "手机短信验证码出错"
}
}