tsk-71: Add token expiration checks #78
@@ -28,4 +28,10 @@ impl LoginResult {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
serde_json::to_string_pretty(&self)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user