Fix permissions on project component edits (#5526)
This commit is contained in:
@@ -998,12 +998,20 @@ pub async fn project_edit_internal(
|
||||
_project_id: DBProjectId,
|
||||
edit: Option<Option<E>>,
|
||||
mut component: &mut Option<E::Component>,
|
||||
perms: ProjectPermissions,
|
||||
) -> Result<(), ApiError> {
|
||||
let Some(edit) = edit else {
|
||||
// component is not specified in the input JSON - leave alone
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
if !perms.contains(ProjectPermissions::EDIT_DETAILS) {
|
||||
return Err(ApiError::CustomAuthentication(
|
||||
"You do not have the permissions to edit the components of this project!"
|
||||
.to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
match (&mut component, edit) {
|
||||
(None, None) => {}
|
||||
(Some(_), None) => {
|
||||
@@ -1041,6 +1049,7 @@ pub async fn project_edit_internal(
|
||||
id,
|
||||
new_project.minecraft_server,
|
||||
&mut project_item.inner.components.minecraft_server,
|
||||
perms,
|
||||
)
|
||||
.await?;
|
||||
update(
|
||||
@@ -1048,6 +1057,7 @@ pub async fn project_edit_internal(
|
||||
id,
|
||||
new_project.minecraft_java_server,
|
||||
&mut project_item.inner.components.minecraft_java_server,
|
||||
perms,
|
||||
)
|
||||
.await?;
|
||||
update(
|
||||
@@ -1055,6 +1065,7 @@ pub async fn project_edit_internal(
|
||||
id,
|
||||
new_project.minecraft_bedrock_server,
|
||||
&mut project_item.inner.components.minecraft_bedrock_server,
|
||||
perms,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user