Skip to content

Commit 08af881

Browse files
committed
examples: Update multi-tenant dependencies
1 parent 544e177 commit 08af881

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

examples/postgres/multi-tenant/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tracing-subscriber = "0.3.19"
1717

1818
rust_decimal = "1.36.0"
1919

20-
rand = "0.8.5"
20+
rand = "0.9.1"
2121

2222
[dependencies.sqlx]
2323
# version = "0.9.0"

examples/postgres/multi-tenant/accounts/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ argon2 = { version = "0.5.3", features = ["password-hash"] }
1010
password-hash = { version = "0.5", features = ["std"] }
1111

1212
uuid = { version = "1", features = ["serde"] }
13-
thiserror = "1"
14-
rand = "0.8"
13+
thiserror = "2"
14+
rand = "0.9.1"
1515

1616
time = { version = "0.3.37", features = ["serde"] }
1717

examples/postgres/multi-tenant/accounts/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use argon2::{password_hash, Argon2, PasswordHasher, PasswordVerifier};
2-
use password_hash::PasswordHashString;
3-
use rand::distributions::{Alphanumeric, DistString};
2+
use password_hash::{rand_core::OsRng, PasswordHashString};
3+
use rand::distr::{Alphanumeric, SampleString};
44
use sqlx::{Acquire, Executor, PgTransaction, Postgres};
55
use std::sync::Arc;
66
use uuid::Uuid;
@@ -129,7 +129,7 @@ impl AccountsManager {
129129
// We transfer ownership to the blocking task and back to ensure Tokio doesn't spawn
130130
// excess threads.
131131
let (_guard, res) = tokio::task::spawn_blocking(move || {
132-
let salt = password_hash::SaltString::generate(rand::thread_rng());
132+
let salt = password_hash::SaltString::generate(&mut OsRng);
133133
(
134134
guard,
135135
Argon2::default()
@@ -279,6 +279,6 @@ impl SessionToken {
279279
const LEN: usize = 32;
280280

281281
fn generate() -> Self {
282-
SessionToken(Alphanumeric.sample_string(&mut rand::thread_rng(), Self::LEN))
282+
SessionToken(Alphanumeric.sample_string(&mut rand::rng(), Self::LEN))
283283
}
284284
}

examples/postgres/multi-tenant/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use accounts::AccountsManager;
22
use color_eyre::eyre;
33
use color_eyre::eyre::{Context, OptionExt};
4-
use rand::distributions::{Alphanumeric, DistString};
4+
use rand::distr::{Alphanumeric, SampleString};
55
use sqlx::Connection;
66

77
#[tokio::main]
@@ -31,7 +31,7 @@ async fn main() -> eyre::Result<()> {
3131

3232
// POST /account
3333
let user_email = format!("user{}@example.com", rand::random::<u32>());
34-
let user_password = Alphanumeric.sample_string(&mut rand::thread_rng(), 16);
34+
let user_password = Alphanumeric.sample_string(&mut rand::rng(), 16);
3535

3636
// Requires an externally managed transaction in case any application-specific records
3737
// should be created after the actual account record.

0 commit comments

Comments
 (0)