diff options
| author | Tolmachev Igor <me@igorek.dev> | 2025-12-07 02:04:56 +0300 |
|---|---|---|
| committer | Tolmachev Igor <me@igorek.dev> | 2025-12-07 02:04:56 +0300 |
| commit | 32afe3f89372063b974f56bf1fd65afa20ab5bf6 (patch) | |
| tree | 5c5ff3c2b198cdc91bb547711bf7ddea6dff4173 /src/routers/account.rs | |
| parent | e864d2653d50ba1c920776aaa14a1625c9fc9da4 (diff) | |
| download | queue_server-32afe3f89372063b974f56bf1fd65afa20ab5bf6.tar.gz queue_server-32afe3f89372063b974f56bf1fd65afa20ab5bf6.zip | |
Diffstat (limited to 'src/routers/account.rs')
| -rw-r--r-- | src/routers/account.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/routers/account.rs b/src/routers/account.rs index e39327a..14bc25b 100644 --- a/src/routers/account.rs +++ b/src/routers/account.rs | |||
| @@ -24,7 +24,7 @@ use crate::{ | |||
| 24 | struct Token { | 24 | struct Token { |
| 25 | #[schema(examples("eyJ0eXAiO..."))] | 25 | #[schema(examples("eyJ0eXAiO..."))] |
| 26 | token: String, | 26 | token: String, |
| 27 | expired_at: DateTime<Utc>, | 27 | expiration_date: DateTime<Utc>, |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | #[derive(Deserialize, ToSchema)] | 30 | #[derive(Deserialize, ToSchema)] |
| @@ -182,19 +182,22 @@ async fn login( | |||
| 182 | return Err(ClientError::InvalidPassword.into()); | 182 | return Err(ClientError::InvalidPassword.into()); |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | let expired_at = Utc::now() + Duration::days(req.token_lifetime as i64); | 185 | let expiration_date = Utc::now() + Duration::days(req.token_lifetime as i64); |
| 186 | 186 | ||
| 187 | let token = create_jwt( | 187 | let token = create_jwt( |
| 188 | &JwtClaims { | 188 | &JwtClaims { |
| 189 | sub: user.id, | 189 | sub: user.id, |
| 190 | iat: user.password_issue_date.and_utc().timestamp(), | 190 | iat: user.password_issue_date.and_utc().timestamp(), |
| 191 | exp: expired_at.timestamp(), | 191 | exp: expiration_date.timestamp(), |
| 192 | }, | 192 | }, |
| 193 | &state.secret, | 193 | &state.secret, |
| 194 | ) | 194 | ) |
| 195 | .map_err(|e| ServerError::Token(e.to_string()))?; | 195 | .map_err(|e| ServerError::Token(e.to_string()))?; |
| 196 | 196 | ||
| 197 | Ok(SuccessResponse::ok(Token { token, expired_at })) | 197 | Ok(SuccessResponse::ok(Token { |
| 198 | token, | ||
| 199 | expiration_date, | ||
| 200 | })) | ||
| 198 | } | 201 | } |
| 199 | 202 | ||
| 200 | #[utoipa::path( | 203 | #[utoipa::path( |
