fix(auth): 统一登录码参数名为 code(与前端保持一致)

This commit is contained in:
2026-04-24 10:56:33 +08:00
parent 034aa66ed8
commit c66d1303ef

View File

@@ -447,11 +447,11 @@ pub async fn web_generate_login_code(
/// 确认网页端登录(小程序调用)
/// POST /api/web-login/confirm
/// Body: { short_code: string }
/// Body: { code: string }
/// 后端查询登录码,找到了就生成 JWT更新 token 字段,删除登录码
#[derive(Debug, Deserialize)]
pub struct WebLoginConfirmRequest {
pub short_code: String,
pub code: String,
}
/// 确认登录响应
@@ -469,7 +469,7 @@ pub async fn web_login_confirm(
req: web::Json<WebLoginConfirmRequest>,
app_state: web::Data<AppState>,
) -> impl Responder {
let short_code = req.short_code.trim();
let short_code = req.code.trim();
// 查找登录码(模糊匹配,因为存入的是 ASD-XXXXXX 格式)
let record: Option<(String, String, chrono::DateTime<chrono::Utc>, Option<i32>)> = sqlx::query_as(