mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-22 06:47:56 +01:00
Only return use
interface if machine is currently free or reserved by me
This commit is contained in:
parent
4feb21e7fc
commit
069819bb9a
@ -216,9 +216,18 @@ async fn fill_machine_builder(
|
|||||||
builder.set_urn(&format!("urn:fabaccess:resource:{}", id.as_ref()));
|
builder.set_urn(&format!("urn:fabaccess:resource:{}", id.as_ref()));
|
||||||
|
|
||||||
let machineapi = Machine::new(user.clone(), perms, machine.clone());
|
let machineapi = Machine::new(user.clone(), perms, machine.clone());
|
||||||
if perms.write {
|
let state = machine.get_status().await;
|
||||||
|
|
||||||
|
// Only set `use` interf if machine could be used by the user.
|
||||||
|
if perms.write && match &state {
|
||||||
|
Status::Free => true,
|
||||||
|
Status::Reserved(reserver) if reserver == user => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
{
|
||||||
builder.set_use(capnp_rpc::new_client(machineapi.clone()));
|
builder.set_use(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()));
|
||||||
//builder.set_check(capnp_rpc::new_client(machineapi.clone()));
|
//builder.set_check(capnp_rpc::new_client(machineapi.clone()));
|
||||||
@ -228,12 +237,11 @@ async fn fill_machine_builder(
|
|||||||
builder.set_admin(capnp_rpc::new_client(machineapi.clone()));
|
builder.set_admin(capnp_rpc::new_client(machineapi.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let s = match state {
|
||||||
let s = match machine.get_status().await {
|
|
||||||
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(u) => {
|
Status::InUse(ref u) => {
|
||||||
if let Some(owner) = u.as_ref() {
|
if let Some(owner) = u.as_ref() {
|
||||||
if owner == user {
|
if owner == user {
|
||||||
builder.set_inuse(capnp_rpc::new_client(machineapi.clone()));
|
builder.set_inuse(capnp_rpc::new_client(machineapi.clone()));
|
||||||
|
Loading…
Reference in New Issue
Block a user