diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-10-18 21:14:26 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-10-18 21:14:26 +0200 |
commit | 2845a79b1ffc04600b270bc8ef452763cbefd117 (patch) | |
tree | 6c6c9fe3d5bc57e140d64893fa6d62100a1bc449 /server | |
parent | 434423454db3a7244c0f1e422f1ab2df06f7d867 (diff) |
Fix expired token
Diffstat (limited to 'server')
-rw-r--r-- | server/src/models/auth.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/server/src/models/auth.rs b/server/src/models/auth.rs index 1e466d3..f798eee 100644 --- a/server/src/models/auth.rs +++ b/server/src/models/auth.rs @@ -102,6 +102,13 @@ where let token_data = decode::<Claims>(bearer.token(), &KEYS.decoding, &Validation::default()) .map_err(|_| AppError::InvalidToken)?; + let now = Local::now().timestamp() as usize; + + // Handle the case of expired token + if token_data.claims.exp < now { + return Err(AppError::InvalidToken); + } + Ok(token_data.claims) } } |