Reverse visibility check to properly disclose machines

Machines that you have disclose on are always shown.
Machines you *don't* have `disclose` on are *also* show *iff* you are using them.
This commit is contained in:
Nadja Reitzenstein 2022-03-16 15:09:25 +01:00
parent 069819bb9a
commit cc2b43a9f2

View File

@ -62,6 +62,14 @@ impl machines::Server for Machines {
let mut filtered_v = Vec::with_capacity(v.len()); let mut filtered_v = Vec::with_capacity(v.len());
for (id, machine) in v.into_iter() { for (id, machine) in v.into_iter() {
// Check if the user has disclose. If yes, machines are always shown.
let required_disclose = &machine.desc.privs.disclose;
if session.as_ref().unwrap().perms.iter()
.any(|rule| rule.match_perm(required_disclose))
{
filtered_v.push((id, machine));
} else {
// If no, match their state. Used & reserved machines are also shown
match machine.get_status().await { match machine.get_status().await {
// Always show a machine if they're in use by myself // Always show a machine if they're in use by myself
Status::InUse(ref bywho) => Status::InUse(ref bywho) =>
@ -83,6 +91,7 @@ impl machines::Server for Machines {
} }
} }
} }
}
} }