diff --git a/src/main.rs b/src/main.rs index bbf116f..f75d992 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,7 +90,7 @@ async fn create_user( //let client = redis::Client::open("redis://127.0.0.1/").unwrap(); //let mut con = client.get_connection().unwrap(); - let username = payload.username; + let username = payload.username.trim().to_owned(); let password = payload.password; let row: (i64,) = sqlx::query_as("SELECT COUNT(id) FROM users WHERE username = $1") @@ -137,7 +137,7 @@ async fn authorize(db: impl PgExecutor<'_>, username: &str, password: &str) -> b } async fn auth_user(State(db_pool): State, headers: HeaderMap) -> (StatusCode, Json) { - let username = headers["x-auth-user"].to_str().unwrap_or(""); + let username = headers["x-auth-user"].to_str().unwrap_or("").trim(); let password = headers["x-auth-key"].to_str().unwrap_or(""); let mut tx = db_pool.begin().await.unwrap(); @@ -159,7 +159,7 @@ async fn update_progress( headers: HeaderMap, Json(payload): Json, ) -> StatusCode { - let username = headers["x-auth-user"].to_str().unwrap_or(""); + let username = headers["x-auth-user"].to_str().unwrap_or("").trim(); let password = headers["x-auth-key"].to_str().unwrap_or(""); let mut tx = db_pool.begin().await.unwrap(); @@ -205,7 +205,7 @@ async fn get_progress( headers: HeaderMap, Path(document): Path, ) -> (StatusCode, Json) { - let username = headers["x-auth-user"].to_str().unwrap_or(""); + let username = headers["x-auth-user"].to_str().unwrap_or("").trim(); let password = headers["x-auth-key"].to_str().unwrap_or(""); let mut tx = db_pool.begin().await.unwrap();