core: type user and auth session timestamps

This commit is contained in:
a.tolmachev
2026-04-12 22:11:43 +00:00
parent 624224f089
commit e03d4da925
14 changed files with 156 additions and 44 deletions
+2 -6
View File
@@ -50,7 +50,7 @@ pub struct AuthenticatedSession {
pub struct SessionCookie {
pub session_id: UserSessionId,
pub value: String,
pub expires_at: String,
pub expires_at: OffsetDateTime,
}
pub fn hash_password(password: &str, pepper: &str) -> Result<String, ApiError> {
@@ -100,11 +100,7 @@ pub fn create_session_cookie(settings: &AuthSettings) -> Result<SessionCookie, A
Ok(SessionCookie {
session_id,
value: format!("{secret}.{}", expires_at.unix_timestamp_nanos()),
expires_at: expires_at
.format(&time::format_description::well_known::Rfc3339)
.map_err(|error| {
ApiError::internal(format!("failed to format session expiration: {error}"))
})?,
expires_at,
})
}