You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-06 06:02:40 +03:00
Upgrade chrono and replace deprecated methods usage
This commit is contained in:
@@ -175,11 +175,16 @@ impl std::ops::Deref for AuthorizationGrant {
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_MAX_AGE: Duration = Duration::microseconds(3600 * 24 * 365 * 1000 * 1000);
|
||||
|
||||
impl AuthorizationGrant {
|
||||
#[must_use]
|
||||
pub fn max_auth_time(&self) -> DateTime<Utc> {
|
||||
let max_age: Option<i64> = self.max_age.map(|x| x.get().into());
|
||||
self.created_at - Duration::seconds(max_age.unwrap_or(3600 * 24 * 365))
|
||||
let max_age = self
|
||||
.max_age
|
||||
.and_then(|x| Duration::try_seconds(x.get().into()))
|
||||
.unwrap_or(DEFAULT_MAX_AGE);
|
||||
self.created_at - max_age
|
||||
}
|
||||
|
||||
/// Mark the authorization grant as exchanged.
|
||||
|
@@ -185,10 +185,10 @@ impl UserEmailVerification {
|
||||
pub fn samples(now: chrono::DateTime<Utc>, rng: &mut impl Rng) -> Vec<Self> {
|
||||
let states = [
|
||||
UserEmailVerificationState::AlreadyUsed {
|
||||
when: now - Duration::minutes(5),
|
||||
when: now - Duration::microseconds(5 * 60 * 1000 * 1000),
|
||||
},
|
||||
UserEmailVerificationState::Expired {
|
||||
when: now - Duration::hours(5),
|
||||
when: now - Duration::microseconds(5 * 60 * 1000 * 1000),
|
||||
},
|
||||
UserEmailVerificationState::Valid,
|
||||
];
|
||||
@@ -204,7 +204,7 @@ impl UserEmailVerification {
|
||||
id: Ulid::from_datetime_with_source(now.into(), &mut rng),
|
||||
user_email_id: email.id,
|
||||
code: "123456".to_owned(),
|
||||
created_at: now - Duration::minutes(10),
|
||||
created_at: now - Duration::microseconds(10 * 60 * 1000 * 1000),
|
||||
state: state.clone(),
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user