mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-11 01:53:23 +01:00
Only return caps the user can have
This commit is contained in:
parent
27791ed19b
commit
f4fead00e6
@ -79,20 +79,29 @@ impl machines::Server for Machines {
|
|||||||
builder.set_description(desc);
|
builder.set_description(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
let s = match machine.get_status().await {
|
let machineapi = Machine::new(user.clone(), perms, machine.clone());
|
||||||
|
|
||||||
|
let state = machine.get_status().await;
|
||||||
|
let s = match state {
|
||||||
Status::Free => MachineState::Free,
|
Status::Free => MachineState::Free,
|
||||||
Status::Disabled => MachineState::Disabled,
|
Status::Disabled => MachineState::Disabled,
|
||||||
Status::Blocked(_) => MachineState::Blocked,
|
Status::Blocked(_) => MachineState::Blocked,
|
||||||
Status::InUse(_) => MachineState::InUse,
|
Status::InUse(ref u) => {
|
||||||
|
if let Some(owner) = u.as_ref() {
|
||||||
|
if owner == user {
|
||||||
|
builder.set_inuse(capnp_rpc::new_client(machineapi.clone()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MachineState::InUse
|
||||||
|
},
|
||||||
Status::Reserved(_) => MachineState::Reserved,
|
Status::Reserved(_) => MachineState::Reserved,
|
||||||
Status::ToCheck(_) => MachineState::ToCheck,
|
Status::ToCheck(_) => MachineState::ToCheck,
|
||||||
};
|
};
|
||||||
builder.set_state(s);
|
builder.set_state(s);
|
||||||
|
|
||||||
let machineapi = Machine::new(user.clone(), perms, machine.clone());
|
if perms.write && state == Status::Free {
|
||||||
if perms.write {
|
|
||||||
builder.set_use(capnp_rpc::new_client(machineapi.clone()));
|
builder.set_use(capnp_rpc::new_client(machineapi.clone()));
|
||||||
builder.set_inuse(capnp_rpc::new_client(machineapi.clone()));
|
|
||||||
}
|
}
|
||||||
if perms.manage {
|
if perms.manage {
|
||||||
builder.set_transfer(capnp_rpc::new_client(machineapi.clone()));
|
builder.set_transfer(capnp_rpc::new_client(machineapi.clone()));
|
||||||
|
Loading…
Reference in New Issue
Block a user