diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-12-01 10:18:51 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-12-01 10:18:51 +0100 |
commit | 4371ba5f0916147e8d60237d1e2fbb6a1fdf834a (patch) | |
tree | ba78ed9d1b7724c5d4587ba0987a74b7a58af5fb /server/src/errors.rs | |
parent | 1177bd52c49789f2b38d9cb961fb87fbc0f1f844 (diff) |
Replace /me endpoint with /:id
Diffstat (limited to 'server/src/errors.rs')
-rw-r--r-- | server/src/errors.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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!({ |