Skip to content

Commit

Permalink
chore(dev): update mongo db v7 -> v8; update mongodb rust driver
Browse files Browse the repository at this point in the history
  • Loading branch information
esteinig committed Mar 5, 2025
1 parent 37c998b commit 83d7961
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 164 deletions.
4 changes: 2 additions & 2 deletions cerebro/stack/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ impl CerebroClient {

self.handle_response::<serde_json::Value>(
response,
Some(&format!("Project `{}` created successfully", name)),
"Project creation failed",
Some(&format!("Database `{}` created successfully", name)),
"Database creation failed",
)?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cerebro/stack/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ uuid = { version = "1.2.1", features = ["v4", "fast-rng", "macro-diagnostics", "
actix-web = "4"
actix-cors = "0.6"
fancy-regex = "0.11.0"
mongodb = "2.4.0"
mongodb = "3.2.1"
futures = "0.3.0"
reqwest = { version = "0.11.16", features = ["blocking", "json"] }
jsonwebtoken = "8.3.0"
Expand Down
12 changes: 6 additions & 6 deletions cerebro/stack/server/src/api/auth/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async fn login_handler(

// Find the user in the database
let user = match user_collection
.find_one(doc! { "email": &body.email }, None)
.find_one(doc! { "email": &body.email })
.await
.unwrap()
{
Expand Down Expand Up @@ -282,7 +282,7 @@ async fn refresh_access_token_handler(

// Find the user in the database
let user = match user_collection
.find_one(doc! { "id": format!("{}", &user_id_uuid) }, None)
.find_one(doc! { "id": format!("{}", &user_id_uuid) })
.await
.unwrap()
{
Expand Down Expand Up @@ -457,7 +457,7 @@ async fn verification_email_handler(

// Find the user in the database
let user = match user_collection
.find_one(doc! { "id": &user_id }, None)
.find_one(doc! { "id": &user_id })
.await
{
Ok(Some(user)) => user,
Expand Down Expand Up @@ -563,7 +563,7 @@ async fn password_email_handler(

// Find the user in the database
let user = match user_collection
.find_one(doc! { "id": &user_id }, None)
.find_one(doc! { "id": &user_id })
.await
{
Ok(Some(user)) => user,
Expand Down Expand Up @@ -758,7 +758,7 @@ async fn reset_password_handler(
// Also sets verified status, as we have confirmed or reset password by user email
match user_collection.find_one_and_update(
doc! { "id": &user.id },
doc! { "$set": { "password": hashed_password, "verified": true } }, None
doc! { "$set": { "password": hashed_password, "verified": true } }
).await
{
Ok(None) => return error_response,
Expand Down Expand Up @@ -818,7 +818,7 @@ async fn check_one_time_token_and_user(
};

let user = match user_collection
.find_one(doc! { "id": &access_token_details.user_id.to_string() }, None)
.find_one(doc! { "id": &access_token_details.user_id.to_string() })
.await
{
Ok(None) => return Err(error_response),
Expand Down
12 changes: 6 additions & 6 deletions cerebro/stack/server/src/api/auth/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl FromRequest for JwtUserMiddleware {
let user_collection: Collection<User> = get_cerebro_db_collection(&data, AdminCollection::Users);

let query_result = user_collection
.find_one(mongodb::bson::doc! { "id": format!("{}", &user_id_uuid) }, None)
.find_one(mongodb::bson::doc! { "id": format!("{}", &user_id_uuid) })
.await;

match query_result {
Expand Down Expand Up @@ -433,7 +433,7 @@ impl FromRequest for JwtDataMiddleware {
let user_collection: Collection<User> = get_cerebro_db_collection(&data, AdminCollection::Users);

let query_result = user_collection
.find_one(mongodb::bson::doc! { "id": format!("{}", &user_id_uuid) }, None)
.find_one(mongodb::bson::doc! { "id": format!("{}", &user_id_uuid) })
.await;

match query_result {
Expand Down Expand Up @@ -514,7 +514,7 @@ impl FromRequest for JwtDataMiddleware {
]
}
]
}, None)
})
.await
},
(Some(database), None) => {
Expand All @@ -534,7 +534,7 @@ impl FromRequest for JwtDataMiddleware {
]
}
]
}, None)
})
.await
},
(None, Some(_)) => {
Expand All @@ -555,7 +555,7 @@ impl FromRequest for JwtDataMiddleware {
},
{ "users": &user_id }
]
}, None)
})
.await
}
};
Expand Down Expand Up @@ -717,7 +717,7 @@ impl FromRequest for JwtAdminMiddleware {
let user_collection: Collection<User> = get_cerebro_db_collection(&data, AdminCollection::Users);

let query_result = user_collection
.find_one(mongodb::bson::doc! { "id": format!("{}", &user_id_uuid) }, None)
.find_one(mongodb::bson::doc! { "id": format!("{}", &user_id_uuid) })
.await;

match query_result {
Expand Down
Loading

0 comments on commit 83d7961

Please sign in to comment.