fix: 修复多处代码质量问题-移除unwrap/println/dead-code/重复代码/错误吞咽
This commit is contained in:
@@ -5,16 +5,14 @@ use reqwest::Client;
|
||||
use sqlx::postgres::PgPool;
|
||||
use tracing::{debug, error, info, warn};
|
||||
|
||||
use crate::auth::{generate_token, generate_refresh_token, verify_refresh_token};
|
||||
use crate::auth::{generate_token, generate_refresh_token};
|
||||
use crate::db;
|
||||
use crate::error::{AppError, ErrorResponse};
|
||||
use crate::models::Claims;
|
||||
use crate::error::ErrorResponse;
|
||||
use crate::models::{
|
||||
AppState, LoginResponse, RefreshTokenRequest, TokenRefreshResponse,
|
||||
WeChatApiResponse, WeChatLoginRequest,
|
||||
};
|
||||
use crate::rate_limiter::LOGIN_RATE_LIMITER;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[post("/api/login")]
|
||||
pub async fn login(
|
||||
@@ -248,7 +246,7 @@ pub async fn mock_login(
|
||||
let user_id = match query.user_id {
|
||||
Some(id) => {
|
||||
// 验证用户存在
|
||||
match sqlx::query_as::<_, (i32,)>(("SELECT id FROM users WHERE id = $1"))
|
||||
match sqlx::query_as::<_, (i32,)>("SELECT id FROM users WHERE id = $1" )
|
||||
.bind(id)
|
||||
.fetch_optional(pool.get_ref())
|
||||
.await
|
||||
@@ -447,8 +445,8 @@ pub async fn web_generate_login_code(
|
||||
.map(|_| {
|
||||
let chars = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
let idx = (Utc::now().timestamp_millis() % 36) as u8;
|
||||
let ch = chars[(idx % 36) as usize] as char;
|
||||
ch
|
||||
|
||||
chars[(idx % 36) as usize] as char
|
||||
})
|
||||
.collect();
|
||||
let ts = Utc::now().timestamp();
|
||||
|
||||
Reference in New Issue
Block a user