You've already forked AstralRinth
forked from didirus/AstralRinth
Fix file uploading for admins (#519)
This commit is contained in:
@@ -520,27 +520,29 @@ async fn upload_file_to_version_inner(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let team_member = models::TeamMember::get_from_user_id_version(
|
if !user.role.is_admin() {
|
||||||
version_id,
|
let team_member = models::TeamMember::get_from_user_id_version(
|
||||||
user.id.into(),
|
version_id,
|
||||||
&mut *transaction,
|
user.id.into(),
|
||||||
)
|
&mut *transaction,
|
||||||
.await?
|
|
||||||
.ok_or_else(|| {
|
|
||||||
CreateError::CustomAuthenticationError(
|
|
||||||
"You don't have permission to upload files to this version!"
|
|
||||||
.to_string(),
|
|
||||||
)
|
)
|
||||||
})?;
|
.await?
|
||||||
|
.ok_or_else(|| {
|
||||||
|
CreateError::CustomAuthenticationError(
|
||||||
|
"You don't have permission to upload files to this version!"
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
if !team_member
|
if !team_member
|
||||||
.permissions
|
.permissions
|
||||||
.contains(Permissions::UPLOAD_VERSION)
|
.contains(Permissions::UPLOAD_VERSION)
|
||||||
{
|
{
|
||||||
return Err(CreateError::CustomAuthenticationError(
|
return Err(CreateError::CustomAuthenticationError(
|
||||||
"You don't have permission to upload files to this version!"
|
"You don't have permission to upload files to this version!"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let project_id = ProjectId(version.inner.project_id.0 as u64);
|
let project_id = ProjectId(version.inner.project_id.0 as u64);
|
||||||
|
|||||||
Reference in New Issue
Block a user