From 129b0f198ff15b02dda1b8de47d8916d63ed8c5c Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Tue, 25 Oct 2022 18:55:39 +0200 Subject: [PATCH] refactor: error handling --- api/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/lib.rs b/api/src/lib.rs index ab73f40..26e2210 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -4,6 +4,7 @@ extern crate rocket; use guard::candidate_jwt::TokenRequest; use portfolio_core::services::candidate_service::CandidateService; use requests::LoginRequest; +use rocket::http::Status; use rocket::{Rocket, Build}; use rocket::serde::json::Json; use rocket::fairing::{self, AdHoc}; @@ -52,7 +53,7 @@ async fn login(conn: Connection<'_, Db>, login_form: Json) -> Resu if jwt.is_some() { return Ok(jwt.unwrap()) } - Ok("jwt here".to_owned()) + Err(Custom(Status::Unauthorized, "Invalid credentials".to_string())) } #[get("/whoami")]