Skip to content

Commit

Permalink
Merge pull request #222 from DaCatBeam/221-Corrected-Forbidden-Error-…
Browse files Browse the repository at this point in the history
…Enum

Corrected Error::FORBIDDEN to Error::Forbidden
  • Loading branch information
indpurvesh authored Aug 19, 2024
2 parents d2164f4 + 13c0200 commit 9343771
Show file tree
Hide file tree
Showing 29 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(""),
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/asset/asset_table_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/asset/store_asset_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/component/component_table_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/component/fetch_component_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/component/store_component_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/component/update_component_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/model/fetch_model_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/model/model_table_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/model/put_model_identifier_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/model/store_model_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/model/update_model_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/page/fetch_page_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/page/page_table_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/page/put_page_identifier_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/page/store_page_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/page/update_page_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/role/fetch_role_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/role/put_role_identifier_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/role/role_table_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/role/store_role_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/role/update_role_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/setting/setting_all_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?))
Expand Down
2 changes: 1 addition & 1 deletion src/api/handlers/setting/update_setting_all_api_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum Error {

AuthenticationError,

FORBIDDEN
Forbidden
}

impl core::fmt::Display for Error {
Expand Down Expand Up @@ -123,7 +123,7 @@ impl IntoResponse for Error {
};
(StatusCode::UNAUTHORIZED, error_response).into_response()
},
Error::FORBIDDEN => {
Error::Forbidden => {
let mut errors: Vec<ErrorMessage> = vec![];
let error_message = ErrorMessage {
key: String::from("email"),
Expand Down

0 comments on commit 9343771

Please sign in to comment.