P0 - Panic 风险修复: - payment.rs: unwrap() → let-else safe handling - payment.rs: get_jwt_secret() expect → Result/AppError - auth.rs: openid 切片添加 len >= 8 守卫 - main.rs: 启动时 expect → unwrap_or_else 描述性 panic - main.rs: Directive::from_str 添加 fallback P1 - 逻辑/安全修复: - payment.rs: urlencoding() + 解码 bug 修复 (移除 had_escape) - payment.rs: Mock 支付添加 check_mock_payment_allowed 检查 - db.rs: 永久会员 NULL → 2099-12-31 一致化 - user.rs: 维护模式添加安全说明注释 - 自动清理 unused_variables 警告 (_is_mobile) P2 - 错误吞没修复: - main.rs: 3 处定时任务 let _ = → if let Err = tracing::error! - db.rs + admin.rs: 7 处通知/审计日志 let _ = → tracing::warn! - auth.rs: refresh token 保存 add warn 日志 P3 - 死代码清理: - models.rs: 移除 TokenResponse (dead) - models.rs: 移除 AppState 中 5 个未使用字段 (env var 直接读取) - error.rs: 移除 3 个 dead ErrorResponse 方法 - rate_limiter.rs: extract_client_ip_from_header → #[cfg(test)] - models.rs: 注释 typo fix (user_ytpe → user_type) - db.rs: RefreshToken 添加 deserialization 注释 Shell 脚本修复: - deploy.sh: run_migrations 移到 restart_service 之前 - test.sh: 移除 EXIT trap 覆盖; heredoc 引号修复; 维护模式添加 restart - common.sh: mock_key 添加 sed 转义 (防 / & 注入) 验证: cargo check 0 warnings, 8 tests passed
This commit is contained in:
@@ -20,7 +20,7 @@ pub struct Claims {
|
||||
pub user_id: i32,
|
||||
// 自定义字段:openid(可选)
|
||||
pub openid: String,
|
||||
// 自定义字段:user_ytpe
|
||||
// 自定义字段:user_type
|
||||
pub user_type: i32,
|
||||
}
|
||||
|
||||
@@ -51,24 +51,6 @@ impl LoginResponse {
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容旧的 TokenResponse
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
pub struct TokenResponse {
|
||||
pub success: bool,
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl TokenResponse {
|
||||
pub fn new(token: String) -> Self {
|
||||
Self {
|
||||
success: true,
|
||||
token,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh Token 请求
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct RefreshTokenRequest {
|
||||
@@ -347,17 +329,6 @@ pub struct AppState {
|
||||
pub jwt_secret: String,
|
||||
pub wechat_appid: String,
|
||||
pub wechat_secret: String,
|
||||
#[allow(dead_code)]
|
||||
pub free_user_data_limit: i32,
|
||||
// ===== 支付宝配置 =====
|
||||
#[allow(dead_code)]
|
||||
pub alipay_app_id: Option<String>,
|
||||
#[allow(dead_code)]
|
||||
pub alipay_private_key: Option<String>,
|
||||
#[allow(dead_code)]
|
||||
pub alipay_alipay_public_key: Option<String>,
|
||||
#[allow(dead_code)]
|
||||
pub alipay_gateway: Option<String>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
@@ -369,14 +340,6 @@ impl AppState {
|
||||
.map_err(|_| "环境变量WECHAT_APPID未设置".to_string())?,
|
||||
wechat_secret: std::env::var("WECHAT_SECRET")
|
||||
.map_err(|_| "环境变量WECHAT_SECRET未设置".to_string())?,
|
||||
free_user_data_limit: std::env::var("FREE_USER_DATA_LIMIT")
|
||||
.map(|v| v.parse().unwrap_or(20))
|
||||
.unwrap_or(20),
|
||||
// 支付宝配置(可选,未配置时使用模拟支付)
|
||||
alipay_app_id: std::env::var("ALIPAY_APP_ID").ok(),
|
||||
alipay_private_key: std::env::var("ALIPAY_PRIVATE_KEY").ok(),
|
||||
alipay_alipay_public_key: std::env::var("ALIPAY_ALIPAY_PUBLIC_KEY").ok(),
|
||||
alipay_gateway: std::env::var("ALIPAY_GATEWAY").ok(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user