aboutsummaryrefslogtreecommitdiff
path: root/src/routers
diff options
context:
space:
mode:
Diffstat (limited to 'src/routers')
-rw-r--r--src/routers/account.rs11
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::{
24struct Token { 24struct 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(