Compare commits

..
Author SHA1 Message Date
phoenix ca3b0c92d4 cargo update
Release Tagging / release (pull_request) Successful in 29s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Test Suite (pull_request) Successful in 1m12s
Rust Build / Check (pull_request) Successful in 1m28s
Rust Build / build (pull_request) Successful in 57s
Rust Build / Clippy (pull_request) Successful in 1m30s
2026-06-13 16:05:29 -04:00
phoenix f27ca90420 bump: textsender_models 2026-06-13 16:05:08 -04:00
phoenix 50b8f368fb This was there for a reason 2026-06-13 16:04:31 -04:00
phoenix 60ee97eee2 Changing type 2026-06-13 16:02:47 -04:00
phoenix 3710ab46d7 Adding utoipa::ToSchema in derive macro 2026-06-13 16:02:08 -04:00
3 changed files with 6 additions and 28 deletions
Generated
+1 -1
View File
@@ -522,7 +522,7 @@ dependencies = [
[[package]]
name = "textsender_models"
version = "0.3.3"
version = "0.3.1"
dependencies = [
"const_format",
"dotenvy",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "textsender_models"
version = "0.3.3"
version = "0.3.1"
edition = "2024"
rust-version = "1.95"
description = "Models used for the textsender project"
+4 -26
View File
@@ -7,32 +7,11 @@ pub struct Claims {
#[serde(alias = "iss")]
pub issued: String,
#[serde(alias = "exp")]
#[serde(deserialize_with = "deserialize_i64_from_f64")]
pub expired: i64,
#[serde(alias = "iat")]
#[serde(deserialize_with = "deserialize_i64_from_f64")]
pub issued_at: i64,
}
fn deserialize_i64_from_f64<'de, D>(deserializer: D) -> Result<i64, D::Error>
where
D: serde::Deserializer<'de>,
{
let val = f64::deserialize(deserializer)?;
// Handle NaN and infinity cases
if val.is_nan() || val.is_infinite() {
return Err(serde::de::Error::custom("invalid float value"));
}
// Round to nearest integer and convert
let rounded = val.round();
// Check if the rounded value can fit in i64
if rounded < (i64::MIN as f64) || rounded > (i64::MAX as f64) {
Err(serde::de::Error::custom("float out of i64 range"))
} else {
Ok(rounded as i64)
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
pub struct LoginResult {
pub user_id: uuid::Uuid,
@@ -42,7 +21,7 @@ pub struct LoginResult {
pub issued_at: i64,
}
/// Alias for LoginResult
// Alias for LoginResult
pub type Login = LoginResult;
pub fn get_issued() -> time::Result<time::OffsetDateTime> {
@@ -63,10 +42,9 @@ pub struct TokenResource {
pub message: String,
pub issuer: String,
pub audiences: Vec<String>,
pub user_id: uuid::Uuid,
pub id: uuid::Uuid,
}
/// Token type
pub const TOKEN_TYPE: &str = "JWT";
pub fn create_token(
@@ -84,8 +62,8 @@ pub fn create_token(
payload.set_subject(message);
payload.set_issuer(issuer);
payload.set_audience(audiences.clone());
if !token_resource.user_id.is_nil() {
match payload.set_claim("user_id", Some(serde_json::json!(token_resource.user_id))) {
if !token_resource.id.is_nil() {
match payload.set_claim("id", Some(serde_json::json!(token_resource.id))) {
Ok(_) => {}
Err(err) => {
return Err(err);