From 430d25e134da9d7d195855f179420b1a02232311 Mon Sep 17 00:00:00 2001 From: Mubelotix Date: Thu, 29 Aug 2024 14:53:36 +0200 Subject: [PATCH] Add fallback redirect --- src/validate.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/validate.rs b/src/validate.rs index b67b044..63631a4 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -53,11 +53,12 @@ impl<'r, 'o: 'r> Responder<'r, 'o> for JwtToken { let mut response = Response::build(); let response = response.status(Status::Ok) .header(Header::new("Set-Cookie", value)); - if let Some(next) = self.next { - // This could be a nice open-redirect vulnerability here but it actually can't be exploited - response.status(Status::SeeOther); - response.header(Header::new("Location", next)); - } + + // This could be a nice open-redirect vulnerability here but it actually can't be exploited + let next = self.next.unwrap_or_else(|| "/login".to_string()); + response.status(Status::SeeOther); + response.header(Header::new("Location", next)); + Ok(response.finalize()) } }