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]]
|
||||
name = "icarus_models"
|
||||
version = "0.7.3"
|
||||
version = "0.7.2"
|
||||
dependencies = [
|
||||
"josekit",
|
||||
"rand",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "icarus_models"
|
||||
version = "0.7.3"
|
||||
version = "0.7.2"
|
||||
edition = "2024"
|
||||
rust-version = "1.90"
|
||||
description = "models used for the icarus project"
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::default::Default;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct LoginResult {
|
||||
pub id: uuid::Uuid,
|
||||
pub username: String,
|
||||
@@ -12,14 +12,20 @@ pub struct LoginResult {
|
||||
pub expiration: i64,
|
||||
}
|
||||
|
||||
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
|
||||
impl Default for LoginResult {
|
||||
fn default() -> Self {
|
||||
LoginResult {
|
||||
id: uuid::Uuid::nil(),
|
||||
username: String::new(),
|
||||
token: String::new(),
|
||||
token_type: String::new(),
|
||||
expiration: -1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LoginResult {
|
||||
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
|
||||
serde_json::to_string_pretty(&self)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user