Skip to content

Commit 33ccd47

Browse files
code rabbit suggestions
1 parent a55dac7 commit 33ccd47

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/handlers/http/rbac.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub async fn get_role(userid: web::Path<String>) -> Result<impl Responder, RBACE
224224
// Handler for DELETE /api/v1/user/delete/{userid}
225225
pub async fn delete_user(userid: web::Path<String>) -> Result<impl Responder, RBACError> {
226226
let userid = userid.into_inner();
227-
227+
let _guard = UPDATE_LOCK.lock().await;
228228
// if user is a part of any groups then don't allow deletion
229229
if !Users.get_user_groups(&userid).is_empty() {
230230
return Err(RBACError::InvalidDeletionRequest(format!(
@@ -243,8 +243,6 @@ pub async fn delete_user(userid: web::Path<String>) -> Result<impl Responder, RB
243243
return Err(RBACError::UserDoesNotExist);
244244
};
245245

246-
let _guard = UPDATE_LOCK.lock().await;
247-
248246
// delete from parseable.json first
249247
let mut metadata = get_metadata().await?;
250248
metadata.users.retain(|user| user.userid() != userid);

src/rbac/user.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,7 @@ impl UserGroup {
407407

408408
/// Get all user IDs in this group
409409
pub fn get_userids(&self) -> Vec<String> {
410-
self.users
411-
.iter()
412-
.map(|u| u.userid().to_string())
413-
.collect()
410+
self.users.iter().map(|u| u.userid().to_string()).collect()
414411
}
415412

416413
/// Add users by converting from User references

0 commit comments

Comments
 (0)