More code
This commit is contained in:
+19
-11
@@ -323,32 +323,40 @@ pub mod endpoint {
|
||||
if hashing::verify_password(&payload.current_password, user.password.clone()).unwrap() {
|
||||
match repo::salt::get(&pool, &user.salt_id).await {
|
||||
Ok(salt) => {
|
||||
// Left off here
|
||||
let updated_salt_string = hashing::generate_salt().unwrap();
|
||||
let mut updated_salt = simodels::user::salt::Salt::default();
|
||||
updated_salt.salt = updated_salt_string.to_string();
|
||||
updated_salt.id = salt.id.clone();
|
||||
let updated_hashed_password = hashing::hash_password(&payload.updated_password, &updated_salt_string).unwrap();
|
||||
|
||||
match repo::user::update_password(&pool, &user, &updated_hashed_password).await {
|
||||
match repo::salt::update_salt(&pool, &salt, &updated_salt.salt).await {
|
||||
Ok(_) => {
|
||||
response.message = "Successful".to_string();
|
||||
response.data.push(user.id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
match repo::user::update_password(&pool, &user, &updated_hashed_password).await {
|
||||
Ok(_) => {
|
||||
response.message = "Successful".to_string();
|
||||
response.data.push(user.id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// invalid
|
||||
response.message = "Invalid".to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user