Skip to content

Commit

Permalink
Foxed update route
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajdip019 committed May 14, 2024
1 parent a263183 commit 3f03aa8
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/config/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pub async fn init_users(mongo_client: Client) {
name: "Debajyoti Saha".to_string(),
email: "[email protected]".to_string(),
role: "admin".to_string(),
password: "debu14@".to_string(),
password: "Debu014@".to_string(),
},
InitUser {
name: "Rajdeep Sengupta".to_string(),
email: "[email protected]".to_string(),
role: "admin".to_string(),
password: "raj19@".to_string(),
password: "Rajdeep19@".to_string(),
},
InitUser {
name: "Sourav Banik".to_string(),
Expand Down
2 changes: 0 additions & 2 deletions src/core/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ impl User {
.await
{
Ok(Some(user)) => {
println!("User {:?}", user);
let decrypted_user = user.decrypt(&dek_data.dek);
println!("Decrypted User {:?}", decrypted_user);
return Ok(decrypted_user);
}
Ok(None) => Err(Error::UserNotFound {
Expand Down
5 changes: 1 addition & 4 deletions src/handlers/user_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ pub async fn update_user_handler(
Err(e) => return Err(e),
};

println!(">> DEK DATA Decrypted: {:?}", dek_data);

// find the user in the users collection using the uid
match collection
.update_one(
Expand All @@ -61,7 +59,7 @@ pub async fn update_user_handler(
},
doc! {
"$set": {
"name": payload.name.clone(),
"name": Encryption::encrypt_data(&payload.name, &dek_data.dek),
"updated_at": DateTime::now(),
}
},
Expand All @@ -76,7 +74,6 @@ pub async fn update_user_handler(
});
}
Ok(Json(UpdateUserResponse {
message: "User updated".to_string(),
email: payload.email.to_owned(),
name: payload.name.to_owned(),
}))
Expand Down
1 change: 0 additions & 1 deletion src/models/user_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct UpdateUserPayload {

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UpdateUserResponse {
pub message: String,
pub email: String,
pub name: String,
}
Expand Down

0 comments on commit 3f03aa8

Please sign in to comment.