tsk-71: Add token expiration checks #78

Merged
phoenix merged 9 commits from tsk-71 into next-v0.8 2025-10-19 02:18:29 +00:00
Showing only changes of commit 25d2e38133 - Show all commits

View File

@@ -44,6 +44,12 @@ impl AccessToken {
pub fn bearer_token(&self) -> String { pub fn bearer_token(&self) -> String {
format!("Bearer {}", self.token) 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 { impl Token {
@@ -51,9 +57,10 @@ impl Token {
serde_json::to_string_pretty(&self) serde_json::to_string_pretty(&self)
} }
// TODO: Implement
pub fn token_expired(&self) -> bool { 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 { pub fn contains_scope(&self, des_scope: &String) -> bool {