diff --git a/Cargo.lock b/Cargo.lock index f3125fc..dc107d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,7 +248,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "authifier" -version = "1.0.14" +version = "1.0.15" dependencies = [ "async-std", "async-trait", @@ -2403,7 +2403,7 @@ dependencies = [ [[package]] name = "rocket_authifier" -version = "1.0.14" +version = "1.0.15" dependencies = [ "async-std", "authifier", @@ -3324,6 +3324,7 @@ checksum = "220b18413e1fe5e85a5580b22f44241f82404a66c792c9f3c9eda74c52d9a22e" dependencies = [ "chrono", "rand", + "serde", ] [[package]] diff --git a/crates/authifier/Cargo.toml b/crates/authifier/Cargo.toml index a5911e3..3eeb750 100644 --- a/crates/authifier/Cargo.toml +++ b/crates/authifier/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "authifier" -version = "1.0.14" +version = "1.0.15" edition = "2021" license = "Apache-2.0" authors = ["Pawel Makles "] @@ -30,7 +30,7 @@ default = ["async-std-runtime", "database-mongodb", "default_inbuilts"] [dependencies] # Lang log = "0.4" -ulid = "0.5.0" +ulid = { version = "0.5.0", features = ["serde"] } rand = "0.8.5" regex = "1.3.9" nanoid = "0.4.0" diff --git a/crates/authifier/src/database/mongo.rs b/crates/authifier/src/database/mongo.rs index 0f82494..8c8d7cc 100644 --- a/crates/authifier/src/database/mongo.rs +++ b/crates/authifier/src/database/mongo.rs @@ -175,7 +175,12 @@ impl AbstractDatabase for MongoDb { // check commits 2025-05-14 (authifier/authifier) for old code loop { - let sessions: Vec = self + #[derive(Deserialize)] + struct SessionId { + _id: Ulid, + } + + let sessions: Vec = self .collection("sessions") .find(doc! { "$or": [ @@ -195,16 +200,15 @@ impl AbstractDatabase for MongoDb { } for session in sessions { - let ulid = - Ulid::from_string(&session.id).expect("Invalid ULID on session!"); - let timestamp = iso8601_timestamp::Timestamp::UNIX_EPOCH - + iso8601_timestamp::Duration::seconds(ulid.datetime().timestamp()); + + iso8601_timestamp::Duration::seconds( + session._id.datetime().timestamp(), + ); self.collection::("sessions") .update_one( doc! { - "_id": &session.id, + "_id": &session._id.to_string(), }, doc! { "$set": { diff --git a/crates/rocket_authifier/Cargo.toml b/crates/rocket_authifier/Cargo.toml index 26c2528..6502033 100644 --- a/crates/rocket_authifier/Cargo.toml +++ b/crates/rocket_authifier/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rocket_authifier" -version = "1.0.14" +version = "1.0.15" edition = "2021" license = "Apache-2.0" authors = ["Pawel Makles "] @@ -21,7 +21,7 @@ example = [ default = [] [dependencies] -authifier = { version = "1.0.14", path = "../authifier", features = [ +authifier = { version = "1.0.15", path = "../authifier", features = [ "rocket_impl", "okapi_impl", ] }