make admins scripts/apps undeletable

This commit is contained in:
Ruben Fiszel
2023-06-02 11:59:52 +02:00
parent 828461f038
commit 5a2b8220dc
2 changed files with 14 additions and 1 deletions
+7
View File
@@ -495,6 +495,13 @@ async fn delete_app(
Path((w_id, path)): Path<(String, StripPath)>,
) -> Result<String> {
let path = path.to_path();
if path == "g/all/setup_app" && w_id == "admins" {
return Err(Error::BadRequest(
"Cannot delete the global setup app".to_string(),
));
}
let mut tx = user_db.begin(&authed).await?;
sqlx::query!(
+7 -1
View File
@@ -842,9 +842,15 @@ async fn delete_script_by_path(
Extension(db): Extension<DB>,
Path((w_id, path)): Path<(String, StripPath)>,
) -> JsonResult<String> {
let mut tx = user_db.begin(&authed).await?;
let path = path.to_path();
if path == "u/admin/hub_sync" && w_id == "admins" {
return Err(Error::BadRequest(
"Cannot delete the global setup app".to_string(),
));
}
let mut tx = user_db.begin(&authed).await?;
let draft_only = sqlx::query_scalar!(
"SELECT draft_only FROM script WHERE path = $1 AND workspace_id = $2",
path,