fix(auth): 修复 web::scope("") 路由顺序导致 web-login 被 JWT 拦截的问题

This commit is contained in:
2026-04-27 09:25:14 +08:00
parent aa84bbc4e6
commit bb20d82d49

View File

@@ -80,6 +80,9 @@ fn create_server_config(
.service(refresh_token) // #[post("/api/refresh-token")](公开接口,无需认证) .service(refresh_token) // #[post("/api/refresh-token")](公开接口,无需认证)
.service(get_weather_details) // #[get("/weather/details")](支持 JWT 或 temp_token公开接口 .service(get_weather_details) // #[get("/weather/details")](支持 JWT 或 temp_token公开接口
.service(health_check) // #[get("/health")](公开接口,无需认证) .service(health_check) // #[get("/health")](公开接口,无需认证)
// 网页登录(无需 JWT登录码本身就是认证凭证- 必须在 JWT scope 之前注册
.service(web_generate_login_code) // POST /api/web-login/code无需 JWT
.service(web_login_confirm) // POST /api/web-login/confirm无需 JWT
// 受保护接口JWT // 受保护接口JWT
.service( .service(
web::scope("") web::scope("")
@@ -99,11 +102,6 @@ fn create_server_config(
.service(add_favorite) // #[post("/api/favorites/{id}")] .service(add_favorite) // #[post("/api/favorites/{id}")]
.service(remove_favorite) // #[delete("/api/favorites/{id}")] .service(remove_favorite) // #[delete("/api/favorites/{id}")]
) )
// 健康检查
.service(health_check)
// 网页登录(无需 JWT登录码本身就是认证凭证
.service(web_generate_login_code) // POST /api/web-login/code无需 JWT
.service(web_login_confirm) // POST /api/web-login/confirm无需 JWT
} }
#[actix_web::main] #[actix_web::main]