tsk-71: Added methods for token expiration
All checks were successful
Rust Build / Test Suite (pull_request) Successful in 53s
Rust Build / Rustfmt (pull_request) Successful in 39s
Rust Build / Clippy (pull_request) Successful in 46s
Rust Build / build (pull_request) Successful in 38s
Rust Build / Check (pull_request) Successful in 38s
All checks were successful
Rust Build / Test Suite (pull_request) Successful in 53s
Rust Build / Rustfmt (pull_request) Successful in 39s
Rust Build / Clippy (pull_request) Successful in 46s
Rust Build / build (pull_request) Successful in 38s
Rust Build / Check (pull_request) Successful in 38s
This commit is contained in:
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