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