Simplifying code
All checks were successful
Rust Build / Check (pull_request) Successful in 46s
Rust Build / Test Suite (pull_request) Successful in 1m6s
Rust Build / Rustfmt (pull_request) Successful in 32s
Rust Build / Clippy (pull_request) Successful in 47s
Rust Build / build (pull_request) Successful in 1m14s
All checks were successful
Rust Build / Check (pull_request) Successful in 46s
Rust Build / Test Suite (pull_request) Successful in 1m6s
Rust Build / Rustfmt (pull_request) Successful in 32s
Rust Build / Clippy (pull_request) Successful in 47s
Rust Build / build (pull_request) Successful in 1m14s
This commit is contained in:
@@ -49,18 +49,9 @@ pub mod endpoint {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Check if user exists
|
// Check if user exists
|
||||||
match repo::user::exists(&pool, &usr.username).await {
|
// match repo::user::exists(&pool, &usr.username).await {
|
||||||
Ok(exists) => {
|
match repo::user::get(&pool, &usr.username).await {
|
||||||
if !exists {
|
Ok(user) => {
|
||||||
return not_found("Not Found").await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
return not_found(&err.to_string()).await;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let user = repo::user::get(&pool, &usr.username).await.unwrap();
|
|
||||||
let salt = repo::salt::get(&pool, &user.salt_id).await.unwrap();
|
let salt = repo::salt::get(&pool, &user.salt_id).await.unwrap();
|
||||||
let salt_str = hashing::get_salt(&salt.salt).unwrap();
|
let salt_str = hashing::get_salt(&salt.salt).unwrap();
|
||||||
|
|
||||||
@@ -70,7 +61,8 @@ pub mod endpoint {
|
|||||||
if hashing::verify_password(&usr.password, hash_password.clone()).unwrap() {
|
if hashing::verify_password(&usr.password, hash_password.clone()).unwrap() {
|
||||||
// Create token
|
// Create token
|
||||||
let key = token_stuff::get_key().unwrap();
|
let key = token_stuff::get_key().unwrap();
|
||||||
let (token_literal, duration) = token_stuff::create_token(&key).unwrap();
|
let (token_literal, duration) =
|
||||||
|
token_stuff::create_token(&key).unwrap();
|
||||||
|
|
||||||
if token_stuff::verify_token(&key, &token_literal) {
|
if token_stuff::verify_token(&key, &token_literal) {
|
||||||
(
|
(
|
||||||
@@ -98,4 +90,11 @@ pub mod endpoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
return not_found(&err.to_string()).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// let user = repo::user::get(&pool, &usr.username).await.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user