From 2845a79b1ffc04600b270bc8ef452763cbefd117 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 18 Oct 2022 21:14:26 +0200 Subject: Fix expired token --- server/src/models/auth.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'server/src') 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::(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) } } -- cgit v1.2.3-18-g5258