Trim username
This commit is contained in:
parent
1461a83fa7
commit
9f23a778d5
1 changed files with 4 additions and 4 deletions
|
@ -90,7 +90,7 @@ async fn create_user(
|
||||||
//let client = redis::Client::open("redis://127.0.0.1/").unwrap();
|
//let client = redis::Client::open("redis://127.0.0.1/").unwrap();
|
||||||
//let mut con = client.get_connection().unwrap();
|
//let mut con = client.get_connection().unwrap();
|
||||||
|
|
||||||
let username = payload.username;
|
let username = payload.username.trim().to_owned();
|
||||||
let password = payload.password;
|
let password = payload.password;
|
||||||
|
|
||||||
let row: (i64,) = sqlx::query_as("SELECT COUNT(id) FROM users WHERE username = $1")
|
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<PgPool>, headers: HeaderMap) -> (StatusCode, Json<Value>) {
|
async fn auth_user(State(db_pool): State<PgPool>, headers: HeaderMap) -> (StatusCode, Json<Value>) {
|
||||||
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 password = headers["x-auth-key"].to_str().unwrap_or("");
|
||||||
|
|
||||||
let mut tx = db_pool.begin().await.unwrap();
|
let mut tx = db_pool.begin().await.unwrap();
|
||||||
|
@ -159,7 +159,7 @@ async fn update_progress(
|
||||||
headers: HeaderMap,
|
headers: HeaderMap,
|
||||||
Json(payload): Json<UpdateProgress>,
|
Json(payload): Json<UpdateProgress>,
|
||||||
) -> StatusCode {
|
) -> 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 password = headers["x-auth-key"].to_str().unwrap_or("");
|
||||||
|
|
||||||
let mut tx = db_pool.begin().await.unwrap();
|
let mut tx = db_pool.begin().await.unwrap();
|
||||||
|
@ -205,7 +205,7 @@ async fn get_progress(
|
||||||
headers: HeaderMap,
|
headers: HeaderMap,
|
||||||
Path(document): Path<String>,
|
Path(document): Path<String>,
|
||||||
) -> (StatusCode, Json<Value>) {
|
) -> (StatusCode, Json<Value>) {
|
||||||
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 password = headers["x-auth-key"].to_str().unwrap_or("");
|
||||||
|
|
||||||
let mut tx = db_pool.begin().await.unwrap();
|
let mut tx = db_pool.begin().await.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue