Compare commits
4 Commits
v0.7.3-nex
...
194cd9e622
| Author | SHA1 | Date | |
|---|---|---|---|
|
194cd9e622
|
|||
|
25d2e38133
|
|||
|
6851fdfdde
|
|||
|
79758b2631
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -149,7 +149,7 @@ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_models"
|
name = "icarus_models"
|
||||||
version = "0.7.3"
|
version = "0.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"josekit",
|
"josekit",
|
||||||
"rand",
|
"rand",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus_models"
|
name = "icarus_models"
|
||||||
version = "0.7.3"
|
version = "0.7.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
description = "models used for the icarus project"
|
description = "models used for the icarus project"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::default::Default;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct LoginResult {
|
pub struct LoginResult {
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
@@ -12,14 +12,20 @@ pub struct LoginResult {
|
|||||||
pub expiration: i64,
|
pub expiration: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginResult {
|
impl Default for LoginResult {
|
||||||
pub fn to_json(&self) -> Result<String, serde_json::Error> {
|
fn default() -> Self {
|
||||||
serde_json::to_string_pretty(&self)
|
LoginResult {
|
||||||
|
id: uuid::Uuid::nil(),
|
||||||
|
username: String::new(),
|
||||||
|
token: String::new(),
|
||||||
|
token_type: String::new(),
|
||||||
|
expiration: -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn token_expired(&self) -> bool {
|
impl LoginResult {
|
||||||
let current_time = time::OffsetDateTime::now_utc();
|
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||||
let expired = time::OffsetDateTime::from_unix_timestamp(self.expiration).unwrap();
|
serde_json::to_string_pretty(&self)
|
||||||
current_time > expired
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user