fix: permissions for location interaction
This commit is contained in:
parent
8f55757360
commit
ec96b3b039
@ -17,15 +17,15 @@ pub async fn delete(
|
||||
return Err(ApplicationError::Unauthorized);
|
||||
}
|
||||
|
||||
let Some(area) = Location::read_by_id(pool.get_ref(), path.id).await? else {
|
||||
let Some(location) = Location::read_by_id(pool.get_ref(), path.id).await? else {
|
||||
return Ok(HttpResponse::NotFound().finish());
|
||||
};
|
||||
|
||||
if user.role == Role::AreaManager && area.id != user.area_id {
|
||||
if user.role == Role::AreaManager && location.area_id != user.area_id {
|
||||
return Err(ApplicationError::Unauthorized);
|
||||
}
|
||||
|
||||
Location::delete(pool.get_ref(), area.id).await?;
|
||||
Location::delete(pool.get_ref(), location.id).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
@ -22,6 +22,10 @@ pub async fn get(
|
||||
return Ok(HttpResponse::NotFound().finish());
|
||||
};
|
||||
|
||||
if user.role == Role::AreaManager && location.area_id != user.area_id {
|
||||
return Err(ApplicationError::Unauthorized);
|
||||
}
|
||||
|
||||
let mut areas = None;
|
||||
|
||||
if user.role == Role::Admin {
|
||||
|
Loading…
x
Reference in New Issue
Block a user