fix update id, don't update user name

This commit is contained in:
jb-alvarado 2023-11-24 08:12:42 +01:00
parent 603a57cf38
commit be2528fbb4
2 changed files with 3 additions and 7 deletions

View File

@ -286,13 +286,9 @@ async fn update_user(
data: web::Json<User>, data: web::Json<User>,
role: AuthDetails<Role>, role: AuthDetails<Role>,
) -> Result<impl Responder, ServiceError> { ) -> Result<impl Responder, ServiceError> {
if id.into_inner() == user.id || role.has_role(&Role::Admin) { if *id == user.id || role.has_role(&Role::Admin) {
let mut fields = String::new(); let mut fields = String::new();
if !data.username.is_empty() {
fields.push_str(format!("username = '{}'", data.username).as_str());
}
if let Some(mail) = data.mail.clone() { if let Some(mail) = data.mail.clone() {
if !fields.is_empty() { if !fields.is_empty() {
fields.push_str(", "); fields.push_str(", ");
@ -314,7 +310,7 @@ async fn update_user(
fields.push_str(format!("password = '{password_hash}', salt = '{salt}'").as_str()); fields.push_str(format!("password = '{password_hash}', salt = '{salt}'").as_str());
} }
if handles::update_user(&pool.into_inner(), user.id, fields) if handles::update_user(&pool.into_inner(), *id, fields)
.await .await
.is_ok() .is_ok()
{ {

@ -1 +1 @@
Subproject commit 36f0919aebc68a57b79c7dbce0e97f4abd115465 Subproject commit e060cbe885a961f295fb4f6f12bc2c86b5f94192