From 4371ba5f0916147e8d60237d1e2fbb6a1fdf834a Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 1 Dec 2022 10:18:51 +0100 Subject: Replace /me endpoint with /:id --- server/src/errors.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'server/src/errors.rs') diff --git a/server/src/errors.rs b/server/src/errors.rs index 72eb837..10c8f32 100644 --- a/server/src/errors.rs +++ b/server/src/errors.rs @@ -17,6 +17,8 @@ pub enum AppError { TokenCreation, /// Raised when a passed token is not valid InvalidToken, + /// Raised if an user wants to do something can't do + Unauthorized, } /// Use `AppError` as response for an endpoint @@ -39,6 +41,10 @@ impl IntoResponse for AppError { "Token creation error".to_string(), ), AppError::InvalidToken => (StatusCode::BAD_REQUEST, "Invalid token".to_string()), + AppError::Unauthorized => ( + StatusCode::UNAUTHORIZED, + "Can't perform this action".to_string(), + ), }; let body = Json(json!({ -- cgit v1.2.3-18-g5258