summaryrefslogtreecommitdiffstats
path: root/src/routes/model.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-09-20 13:53:16 +0000
committerSanto Cariotti <santo@dcariotti.me>2022-09-20 13:53:16 +0000
commit7287390e0398570961fd998652bd180d6fb13b78 (patch)
treee4d5e091ac781a31683fc1dc0c936d82650a6c29 /src/routes/model.rs
parent224b7e52c7a7a02d36a82c070925a2e506b7b2f4 (diff)
Run clippy + add doc
Diffstat (limited to 'src/routes/model.rs')
-rw-r--r--src/routes/model.rs8
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