From 3c4331f9661ee7d15dce960dd65011d2c8b745c9 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Tue, 25 Oct 2022 18:20:49 +0200 Subject: [PATCH] refactor: token request --- api/src/guard/candidate_jwt.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/guard/candidate_jwt.rs b/api/src/guard/candidate_jwt.rs index 977f021..2a96684 100644 --- a/api/src/guard/candidate_jwt.rs +++ b/api/src/guard/candidate_jwt.rs @@ -5,18 +5,18 @@ use rocket::request::{FromRequest, Request}; use portfolio_core::token::candidate_token::CandidateToken; use portfolio_core::token::decode_candidate_token; -pub struct Token(CandidateToken); +pub struct TokenRequest(CandidateToken); #[rocket::async_trait] -impl<'r> FromRequest<'r> for Token { +impl<'r> FromRequest<'r> for TokenRequest { type Error = Status; - async fn from_request(req: &'r Request<'_>) -> Outcome { + async fn from_request(req: &'r Request<'_>) -> Outcome { if let Some(auth) = req.headers().get_one("Authorization") { let auth_string = auth.to_string(); if auth_string.starts_with("Bearer") { let token = auth_string[6..auth_string.len()].trim(); if let Ok(token_data) = decode_candidate_token(token.to_string()) { - return Outcome::Success(Token(token_data.claims)); + return Outcome::Success(TokenRequest(token_data.claims)); } } }