From 25d2e38133f70756aa21ab2116de45243b7b347c Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 21:56:24 -0400 Subject: [PATCH] tsk-71: Added methods for token expiration --- src/token.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/token.rs b/src/token.rs index af23655..c727eff 100644 --- a/src/token.rs +++ b/src/token.rs @@ -44,6 +44,12 @@ impl AccessToken { pub fn bearer_token(&self) -> String { format!("Bearer {}", self.token) } + + pub fn token_expired(&self) -> bool { + let current_time = time::OffsetDateTime::now_utc(); + let expired = time::OffsetDateTime::from_unix_timestamp(self.expiration).unwrap(); + current_time > expired + } } impl Token { @@ -51,9 +57,10 @@ impl Token { serde_json::to_string_pretty(&self) } - // TODO: Implement pub fn token_expired(&self) -> bool { - false + let current_time = time::OffsetDateTime::now_utc(); + let expired = time::OffsetDateTime::from_unix_timestamp(self.expiration).unwrap(); + current_time > expired } pub fn contains_scope(&self, des_scope: &String) -> bool {