From 30b29de8cea3573e73d240de91e44b8855d8ac81 Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:25:24 -0700 Subject: [PATCH] Fix statuses again (#497) * Fix statuses again * Make it compile --- src/routes/projects.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/routes/projects.rs b/src/routes/projects.rs index c6654fcef..ab8a67b9d 100644 --- a/src/routes/projects.rs +++ b/src/routes/projects.rs @@ -457,6 +457,18 @@ pub async fn project_edit( )); } + if !user.role.is_mod() + && !(!project_item.inner.status.is_approved() + && status == &ProjectStatus::Processing + || project_item.inner.status.is_approved() + && status.can_be_requested()) + { + return Err(ApiError::CustomAuthentication( + "You don't have permission to set this status!" + .to_string(), + )); + } + if status == &ProjectStatus::Processing { if project_item.versions.is_empty() { return Err(ApiError::InvalidInput(String::from( @@ -499,15 +511,6 @@ pub async fn project_edit( } } - if (status.is_approved() || !status.can_be_requested()) - && !user.role.is_mod() - { - return Err(ApiError::CustomAuthentication( - "You don't have permission to set this status!" - .to_string(), - )); - } - if status.is_approved() && !project_item.inner.status.is_approved() {