diff options
Diffstat (limited to 'src/routes/model.rs')
| -rw-r--r-- | src/routes/model.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/routes/model.rs b/src/routes/model.rs index 4f935a9..0572977 100644 --- a/src/routes/model.rs +++ b/src/routes/model.rs @@ -109,12 +109,10 @@ async fn delete_model(claims: Claims, Path(model_id): Path<i32>) -> Result<Statu let user = User::find_by_id(claims.user_id).await?; - let uploads: Vec<String> = model.upload_paths().await.unwrap(); + let uploads: Vec<String> = model.list_upload_filepaths().await.unwrap(); - if model.author_id() != user.id { - if !user.is_staff.unwrap() { - return Err(AppError::Unauthorized); - } + if !(model.author_id() == user.id || user.is_staff.unwrap()) { + return Err(AppError::Unauthorized); } // If the model has been deleted, remove all old uploads from the file system |
