tsk-71: Add token expiration checks #78
11
src/token.rs
11
src/token.rs
@@ -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 {
|
||||||
|
Reference in New Issue
Block a user