Compare commits
No commits in common. "master" and "v2.0.0" have entirely different histories.
1 changed files with 7 additions and 4 deletions
11
src/main.rs
11
src/main.rs
|
@ -87,7 +87,10 @@ async fn create_user(
|
|||
State(db_pool): State<PgPool>,
|
||||
Json(payload): Json<User>,
|
||||
) -> (StatusCode, Json<Value>) {
|
||||
let username = payload.username.trim().to_owned();
|
||||
//let client = redis::Client::open("redis://127.0.0.1/").unwrap();
|
||||
//let mut con = client.get_connection().unwrap();
|
||||
|
||||
let username = payload.username;
|
||||
let password = payload.password;
|
||||
|
||||
let row: (i64,) = sqlx::query_as("SELECT COUNT(id) FROM users WHERE username = $1")
|
||||
|
@ -134,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>) {
|
||||
let username = headers["x-auth-user"].to_str().unwrap_or("").trim();
|
||||
let username = headers["x-auth-user"].to_str().unwrap_or("");
|
||||
let password = headers["x-auth-key"].to_str().unwrap_or("");
|
||||
|
||||
let mut tx = db_pool.begin().await.unwrap();
|
||||
|
@ -156,7 +159,7 @@ async fn update_progress(
|
|||
headers: HeaderMap,
|
||||
Json(payload): Json<UpdateProgress>,
|
||||
) -> StatusCode {
|
||||
let username = headers["x-auth-user"].to_str().unwrap_or("").trim();
|
||||
let username = headers["x-auth-user"].to_str().unwrap_or("");
|
||||
let password = headers["x-auth-key"].to_str().unwrap_or("");
|
||||
|
||||
let mut tx = db_pool.begin().await.unwrap();
|
||||
|
@ -202,7 +205,7 @@ async fn get_progress(
|
|||
headers: HeaderMap,
|
||||
Path(document): Path<String>,
|
||||
) -> (StatusCode, Json<Value>) {
|
||||
let username = headers["x-auth-user"].to_str().unwrap_or("").trim();
|
||||
let username = headers["x-auth-user"].to_str().unwrap_or("");
|
||||
let password = headers["x-auth-key"].to_str().unwrap_or("");
|
||||
|
||||
let mut tx = db_pool.begin().await.unwrap();
|
||||
|
|
Loading…
Reference in a new issue