assign pool membership of new isntance using user group membership

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-02-28 02:38:30 +00:00
parent 2e6840ce99
commit eb5b39ea22

View File

@ -186,11 +186,17 @@ app.post("/api/instance", async (req, res) => {
return; return;
} }
let user = await requestPVE(`/access/users/${req.cookies.username}`, "GET", null, null, pveAPIToken);
let group = user.data.data.groups[0];
if (!group) {
res.send({auth: auth, data: {error: `user ${req.cookies.username} has no group membership`}});
}
let action = { let action = {
vmid: req.body.vmid, vmid: req.body.vmid,
cores: req.body.cores, cores: req.body.cores,
memory: req.body.memory, memory: req.body.memory,
pool: req.cookies.username.replace("@ldap", "") pool: group
}; };
if (req.body.type === "lxc") { if (req.body.type === "lxc") {
action.swap = req.body.swap; action.swap = req.body.swap;