update localdb backend interface,

update all references to localdb backend
This commit is contained in:
alu
2024-04-09 21:02:41 +00:00
parent 98479205d9
commit 3ddd1f62d7
12 changed files with 152 additions and 42 deletions
+12 -2
View File
@@ -74,6 +74,11 @@ router.post("/:hostpci/modify", async (req, res) => {
device: req.body.device,
pcie: req.body.pcie
};
const userRealm = req.cookies.username.split("@").at(-1);
const userID = req.cookies.username.replace(`@${userRealm}`, "");
const userObj = { id: userID, realm: userRealm };
// check if type is qemu
if (params.type !== "qemu") {
res.status(500).send({ error: "Type must be qemu (vm)." });
@@ -102,7 +107,7 @@ router.post("/:hostpci/modify", async (req, res) => {
const deviceData = await global.pve.getDeviceInfo(params.node, params.device);
const request = { pci: deviceData.device_name };
// check resource approval
if (!await approveResources(req, req.cookies.username, request, params.node)) {
if (!await approveResources(req, userObj, request, params.node)) {
res.status(500).send({ request, error: `Could not fulfil request for ${deviceData.device_name}.` });
res.end();
return;
@@ -156,6 +161,11 @@ router.post("/create", async (req, res) => {
device: req.body.device,
pcie: req.body.pcie
};
const userRealm = req.cookies.username.split("@").at(-1);
const userID = req.cookies.username.replace(`@${userRealm}`, "");
const userObj = { id: userID, realm: userRealm };
// check if type is qemu
if (params.type !== "qemu") {
res.status(500).send({ error: "Type must be qemu (vm)." });
@@ -182,7 +192,7 @@ router.post("/create", async (req, res) => {
pci: deviceData.device_name
};
// check resource approval
if (!await approveResources(req, req.cookies.username, request, params.node)) {
if (!await approveResources(req, userObj, request, params.node)) {
res.status(500).send({ request, error: `Could not fulfil request for ${deviceData.device_name}.` });
res.end();
return;