From 13c020029bdd9d4203475062843435abc6e51296 Mon Sep 17 00:00:00 2001 From: Ben Rahman Date: Sun, 18 Aug 2024 08:28:35 -0500 Subject: [PATCH] Corrected Error::FORBIDDEN to Error::Forbidden --- src/api/handlers/admin_user/admin_user_table_api_handler.rs | 2 +- src/api/handlers/admin_user/fetch_admin_user_api_handler.rs | 2 +- src/api/handlers/admin_user/store_admin_user_api_handler.rs | 2 +- src/api/handlers/admin_user/update_admin_user_api_handler.rs | 2 +- src/api/handlers/asset/asset_table_api_handler.rs | 2 +- src/api/handlers/asset/store_asset_api_handler.rs | 2 +- src/api/handlers/component/component_table_api_handler.rs | 2 +- src/api/handlers/component/fetch_component_api_handler.rs | 2 +- .../component/put_component_identifier_api_handler.rs | 2 +- src/api/handlers/component/store_component_api_handler.rs | 2 +- src/api/handlers/component/update_component_api_handler.rs | 2 +- src/api/handlers/model/fetch_model_api_handler.rs | 2 +- src/api/handlers/model/model_table_api_handler.rs | 2 +- src/api/handlers/model/put_model_identifier_api_handler.rs | 2 +- src/api/handlers/model/store_model_api_handler.rs | 2 +- src/api/handlers/model/update_model_api_handler.rs | 2 +- src/api/handlers/page/fetch_page_api_handler.rs | 2 +- src/api/handlers/page/page_table_api_handler.rs | 2 +- src/api/handlers/page/put_page_identifier_api_handler.rs | 2 +- src/api/handlers/page/store_page_api_handler.rs | 2 +- src/api/handlers/page/update_page_api_handler.rs | 2 +- src/api/handlers/role/fetch_role_api_handler.rs | 2 +- src/api/handlers/role/put_role_identifier_api_handler.rs | 2 +- src/api/handlers/role/role_table_api_handler.rs | 2 +- src/api/handlers/role/store_role_api_handler.rs | 2 +- src/api/handlers/role/update_role_api_handler.rs | 2 +- src/api/handlers/setting/setting_all_api_handler.rs | 2 +- src/api/handlers/setting/update_setting_all_api_handler.rs | 2 +- src/error.rs | 4 ++-- 29 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/api/handlers/admin_user/admin_user_table_api_handler.rs b/src/api/handlers/admin_user/admin_user_table_api_handler.rs index 6c8eec8f..c86f909a 100644 --- a/src/api/handlers/admin_user/admin_user_table_api_handler.rs +++ b/src/api/handlers/admin_user/admin_user_table_api_handler.rs @@ -20,7 +20,7 @@ pub async fn admin_user_table_api_handler( .has_permission(logged_in_user, String::from("admin_user_table")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let current_page = query_param.page.unwrap_or(0); diff --git a/src/api/handlers/admin_user/fetch_admin_user_api_handler.rs b/src/api/handlers/admin_user/fetch_admin_user_api_handler.rs index dd755b85..6181d5a7 100644 --- a/src/api/handlers/admin_user/fetch_admin_user_api_handler.rs +++ b/src/api/handlers/admin_user/fetch_admin_user_api_handler.rs @@ -21,7 +21,7 @@ pub async fn fetch_admin_user_api_handler( .has_permission(logged_in_user, String::from("get_admin_user")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let admin_user_model = state diff --git a/src/api/handlers/admin_user/store_admin_user_api_handler.rs b/src/api/handlers/admin_user/store_admin_user_api_handler.rs index ebf6e759..be395cd2 100644 --- a/src/api/handlers/admin_user/store_admin_user_api_handler.rs +++ b/src/api/handlers/admin_user/store_admin_user_api_handler.rs @@ -26,7 +26,7 @@ pub async fn store_admin_user_api_handler( .has_permission(logged_in_user.clone(), String::from("admin_user_create")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let mut payload = StoreAdminUserRequest { diff --git a/src/api/handlers/admin_user/update_admin_user_api_handler.rs b/src/api/handlers/admin_user/update_admin_user_api_handler.rs index fb17b193..4d06b96f 100644 --- a/src/api/handlers/admin_user/update_admin_user_api_handler.rs +++ b/src/api/handlers/admin_user/update_admin_user_api_handler.rs @@ -29,7 +29,7 @@ pub async fn update_admin_user_api_handler( .has_permission(logged_in_user.clone(), String::from("admin_user_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let mut payload = UpdateAdminUserRequest { full_name: String::from(""), diff --git a/src/api/handlers/asset/asset_table_api_handler.rs b/src/api/handlers/asset/asset_table_api_handler.rs index e502e164..4b0623cf 100644 --- a/src/api/handlers/asset/asset_table_api_handler.rs +++ b/src/api/handlers/asset/asset_table_api_handler.rs @@ -19,7 +19,7 @@ pub async fn asset_table_api_handler( .has_permission(logged_in_user, String::from("asset_table")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let current_page = query_param.page.unwrap_or(1); diff --git a/src/api/handlers/asset/store_asset_api_handler.rs b/src/api/handlers/asset/store_asset_api_handler.rs index fa633cc7..487592b9 100644 --- a/src/api/handlers/asset/store_asset_api_handler.rs +++ b/src/api/handlers/asset/store_asset_api_handler.rs @@ -28,7 +28,7 @@ pub async fn store_asset_api_handler( .has_permission(logged_in_user.clone(), String::from("asset_create")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let mut creatable_asset_model = CreatableAssetModel::default(); diff --git a/src/api/handlers/component/component_table_api_handler.rs b/src/api/handlers/component/component_table_api_handler.rs index 8cd01c19..a66eec22 100644 --- a/src/api/handlers/component/component_table_api_handler.rs +++ b/src/api/handlers/component/component_table_api_handler.rs @@ -19,7 +19,7 @@ pub async fn component_table_api_handler( .has_permission(logged_in_user, String::from("component_table")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let current_page = query_param.page.unwrap_or(0); diff --git a/src/api/handlers/component/fetch_component_api_handler.rs b/src/api/handlers/component/fetch_component_api_handler.rs index df7e8eaa..30addec2 100644 --- a/src/api/handlers/component/fetch_component_api_handler.rs +++ b/src/api/handlers/component/fetch_component_api_handler.rs @@ -22,7 +22,7 @@ pub async fn fetch_component_api_handler( .has_permission(logged_in_user, String::from("get_component")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let component_model = state diff --git a/src/api/handlers/component/put_component_identifier_api_handler.rs b/src/api/handlers/component/put_component_identifier_api_handler.rs index 03a90ddb..883e1e3e 100644 --- a/src/api/handlers/component/put_component_identifier_api_handler.rs +++ b/src/api/handlers/component/put_component_identifier_api_handler.rs @@ -27,7 +27,7 @@ pub async fn put_component_identifier_api_handler( .has_permission(logged_in_user.clone(), String::from("component_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate(state.clone()).await?; diff --git a/src/api/handlers/component/store_component_api_handler.rs b/src/api/handlers/component/store_component_api_handler.rs index b9da566c..cdb64027 100644 --- a/src/api/handlers/component/store_component_api_handler.rs +++ b/src/api/handlers/component/store_component_api_handler.rs @@ -24,7 +24,7 @@ pub async fn store_component_api_handler( .has_permission(logged_in_user.clone(), String::from("component_create")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/api/handlers/component/update_component_api_handler.rs b/src/api/handlers/component/update_component_api_handler.rs index 17eaab2a..4076f346 100644 --- a/src/api/handlers/component/update_component_api_handler.rs +++ b/src/api/handlers/component/update_component_api_handler.rs @@ -25,7 +25,7 @@ pub async fn update_component_api_handler( .has_permission(logged_in_user.clone(), String::from("component_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/api/handlers/model/fetch_model_api_handler.rs b/src/api/handlers/model/fetch_model_api_handler.rs index 1c9ec4dd..b2e6ac3d 100644 --- a/src/api/handlers/model/fetch_model_api_handler.rs +++ b/src/api/handlers/model/fetch_model_api_handler.rs @@ -22,7 +22,7 @@ pub async fn fetch_model_api_handler( .has_permission(logged_in_user, String::from("get_model")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let model_model = state diff --git a/src/api/handlers/model/model_table_api_handler.rs b/src/api/handlers/model/model_table_api_handler.rs index 817d6db1..24627b25 100644 --- a/src/api/handlers/model/model_table_api_handler.rs +++ b/src/api/handlers/model/model_table_api_handler.rs @@ -19,7 +19,7 @@ pub async fn model_table_api_handler( .has_permission(logged_in_user, String::from("model_table")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let current_page = query_param.page.unwrap_or(0); diff --git a/src/api/handlers/model/put_model_identifier_api_handler.rs b/src/api/handlers/model/put_model_identifier_api_handler.rs index 4fbe352b..7a9f1086 100644 --- a/src/api/handlers/model/put_model_identifier_api_handler.rs +++ b/src/api/handlers/model/put_model_identifier_api_handler.rs @@ -27,7 +27,7 @@ pub async fn put_model_identifier_api_handler( .has_permission(logged_in_user.clone(), String::from("model_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate(state.clone()).await?; diff --git a/src/api/handlers/model/store_model_api_handler.rs b/src/api/handlers/model/store_model_api_handler.rs index 2f454933..537f2a40 100644 --- a/src/api/handlers/model/store_model_api_handler.rs +++ b/src/api/handlers/model/store_model_api_handler.rs @@ -24,7 +24,7 @@ pub async fn store_model_api_handler( .has_permission(logged_in_user.clone(), String::from("model_create")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/api/handlers/model/update_model_api_handler.rs b/src/api/handlers/model/update_model_api_handler.rs index eeda66b4..a610cc13 100644 --- a/src/api/handlers/model/update_model_api_handler.rs +++ b/src/api/handlers/model/update_model_api_handler.rs @@ -24,7 +24,7 @@ pub async fn update_model_api_handler( .has_permission(logged_in_user.clone(), String::from("model_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/api/handlers/page/fetch_page_api_handler.rs b/src/api/handlers/page/fetch_page_api_handler.rs index bce1c470..08fe541a 100644 --- a/src/api/handlers/page/fetch_page_api_handler.rs +++ b/src/api/handlers/page/fetch_page_api_handler.rs @@ -22,7 +22,7 @@ pub async fn fetch_page_api_handler( .has_permission(logged_in_user, String::from("get_page")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let page_model = state diff --git a/src/api/handlers/page/page_table_api_handler.rs b/src/api/handlers/page/page_table_api_handler.rs index 56dc8cff..affc2587 100644 --- a/src/api/handlers/page/page_table_api_handler.rs +++ b/src/api/handlers/page/page_table_api_handler.rs @@ -19,7 +19,7 @@ pub async fn page_table_api_handler( .has_permission(logged_in_user, String::from("page_table")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let current_page = query_param.page.unwrap_or(0); diff --git a/src/api/handlers/page/put_page_identifier_api_handler.rs b/src/api/handlers/page/put_page_identifier_api_handler.rs index 0286f291..74d498e3 100644 --- a/src/api/handlers/page/put_page_identifier_api_handler.rs +++ b/src/api/handlers/page/put_page_identifier_api_handler.rs @@ -27,7 +27,7 @@ pub async fn put_page_identifier_api_handler( .has_permission(logged_in_user.clone(), String::from("page_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate(state.clone()).await?; diff --git a/src/api/handlers/page/store_page_api_handler.rs b/src/api/handlers/page/store_page_api_handler.rs index c155bf6a..ddc0bb35 100644 --- a/src/api/handlers/page/store_page_api_handler.rs +++ b/src/api/handlers/page/store_page_api_handler.rs @@ -24,7 +24,7 @@ pub async fn store_page_api_handler( .has_permission(logged_in_user.clone(), String::from("page_create")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } if !error_messages.is_empty() { diff --git a/src/api/handlers/page/update_page_api_handler.rs b/src/api/handlers/page/update_page_api_handler.rs index 6448fa8d..9f29e68c 100644 --- a/src/api/handlers/page/update_page_api_handler.rs +++ b/src/api/handlers/page/update_page_api_handler.rs @@ -25,7 +25,7 @@ pub async fn update_page_api_handler( .has_permission(logged_in_user.clone(), String::from("page_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/api/handlers/role/fetch_role_api_handler.rs b/src/api/handlers/role/fetch_role_api_handler.rs index a838d7cd..6b9f63f6 100644 --- a/src/api/handlers/role/fetch_role_api_handler.rs +++ b/src/api/handlers/role/fetch_role_api_handler.rs @@ -22,7 +22,7 @@ pub async fn fetch_role_api_handler( .has_permission(logged_in_user, String::from("get_role")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let role_model = state diff --git a/src/api/handlers/role/put_role_identifier_api_handler.rs b/src/api/handlers/role/put_role_identifier_api_handler.rs index 8b1e576d..e6d4aeba 100644 --- a/src/api/handlers/role/put_role_identifier_api_handler.rs +++ b/src/api/handlers/role/put_role_identifier_api_handler.rs @@ -27,7 +27,7 @@ pub async fn put_role_identifier_api_handler( .has_permission(logged_in_user.clone(), String::from("role_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate(state.clone()).await?; diff --git a/src/api/handlers/role/role_table_api_handler.rs b/src/api/handlers/role/role_table_api_handler.rs index 18419316..47ea69a1 100644 --- a/src/api/handlers/role/role_table_api_handler.rs +++ b/src/api/handlers/role/role_table_api_handler.rs @@ -18,7 +18,7 @@ pub async fn role_table_api_handler( .has_permission(logged_in_user, String::from("role_table")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let current_page = query_param.page.unwrap_or(0); diff --git a/src/api/handlers/role/store_role_api_handler.rs b/src/api/handlers/role/store_role_api_handler.rs index 44c5052f..368b60eb 100644 --- a/src/api/handlers/role/store_role_api_handler.rs +++ b/src/api/handlers/role/store_role_api_handler.rs @@ -24,7 +24,7 @@ pub async fn store_role_api_handler( .has_permission(logged_in_user.clone(), String::from("role_create")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/api/handlers/role/update_role_api_handler.rs b/src/api/handlers/role/update_role_api_handler.rs index 56a04466..f8e0cbb6 100644 --- a/src/api/handlers/role/update_role_api_handler.rs +++ b/src/api/handlers/role/update_role_api_handler.rs @@ -24,7 +24,7 @@ pub async fn update_role_api_handler( .has_permission(logged_in_user.clone(), String::from("role_edit")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/api/handlers/setting/setting_all_api_handler.rs b/src/api/handlers/setting/setting_all_api_handler.rs index 8f65f14f..6466ad09 100644 --- a/src/api/handlers/setting/setting_all_api_handler.rs +++ b/src/api/handlers/setting/setting_all_api_handler.rs @@ -18,7 +18,7 @@ pub async fn setting_all_api_handler( .has_permission(logged_in_user, String::from("get_setting")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } Ok(Json(state.setting_service.all(&state.db).await?)) diff --git a/src/api/handlers/setting/update_setting_all_api_handler.rs b/src/api/handlers/setting/update_setting_all_api_handler.rs index 768ed543..16461d4e 100644 --- a/src/api/handlers/setting/update_setting_all_api_handler.rs +++ b/src/api/handlers/setting/update_setting_all_api_handler.rs @@ -20,7 +20,7 @@ pub async fn update_setting_all_api_handler( .has_permission(logged_in_user.clone(), String::from("save_setting")) .await?; if !has_permission_bool { - return Err(Error::FORBIDDEN); + return Err(Error::Forbidden); } let error_messages = payload.validate()?; diff --git a/src/error.rs b/src/error.rs index 1bdef26d..d69013ba 100644 --- a/src/error.rs +++ b/src/error.rs @@ -24,7 +24,7 @@ pub enum Error { AuthenticationError, - FORBIDDEN + Forbidden } impl core::fmt::Display for Error { @@ -123,7 +123,7 @@ impl IntoResponse for Error { }; (StatusCode::UNAUTHORIZED, error_response).into_response() }, - Error::FORBIDDEN => { + Error::Forbidden => { let mut errors: Vec = vec![]; let error_message = ErrorMessage { key: String::from("email"),