From 7287390e0398570961fd998652bd180d6fb13b78 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 20 Sep 2022 15:53:16 +0200 Subject: Run clippy + add doc --- src/routes/model.rs | 8 +++----- src/routes/user.rs | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/routes') 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) -> Result = model.upload_paths().await.unwrap(); + let uploads: Vec = 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 diff --git a/src/routes/user.rs b/src/routes/user.rs index d20f1f6..791e441 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -63,7 +63,7 @@ async fn edit_my_avatar( if user.avatar.is_some() { let avatar_url = user.avatar.as_ref().unwrap(); - delete_upload(&avatar_url)?; + delete_upload(avatar_url)?; } match upload( @@ -93,7 +93,7 @@ async fn delete_my_avatar(claims: Claims) -> Result, AppError> { if user.avatar.is_some() { let avatar_url = user.avatar.as_ref().unwrap(); - delete_upload(&avatar_url)?; + delete_upload(avatar_url)?; } user.edit_avatar(None).await?; -- cgit v1.2.3-71-g8e6c