rbac/wwwroot/gen_sms_code.dspy

29 lines
594 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

phone = params_kw.cellphone
if phone is None:
return {
"status": "error",
"data":{
"message": "没有收到手机号"
}
}
# 使用短信模块发布的sms_engine实例生成验证码参数手机号
try:
xx = await sms_engine.generate_sms_code(phone)
except Exception as e:
debug(f'gen_sms_code error: {e}')
exception(f'gen_sms_code error for {phone}: {e}')
return {
"status": "error",
"data": {
"message": f"发送验证码出错: {e}"
}
}
id, code = xx
debug(f'{id=},{code=}')
return {
"status": "ok",
"data": {
"message": "短信码已生成",
"key": id
}
}