add node restriction
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
116cb14cc5
commit
dcef0bb032
5
main.js
5
main.js
@ -229,6 +229,11 @@ app.post("/api/instance", async (req, res) => {
|
|||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!user.nodes.includes(req.body.node)) {
|
||||||
|
res.status(500).send({error: `Requested node ${req.body.node} is not in allowed nodes [${user.nodes}]`});
|
||||||
|
res.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
let action = {
|
let action = {
|
||||||
vmid: req.body.vmid,
|
vmid: req.body.vmid,
|
||||||
cores: req.body.cores,
|
cores: req.body.cores,
|
||||||
|
4
utils.js
4
utils.js
@ -3,8 +3,8 @@ import { getUserConfig, getResourceConfig } from "./db.js";
|
|||||||
|
|
||||||
export async function getUserData (req, username) {
|
export async function getUserData (req, username) {
|
||||||
let resources = await getAllocatedResources(req, username);
|
let resources = await getAllocatedResources(req, username);
|
||||||
let instances = getUserConfig(req.cookies.username).instances;
|
let user = getUserConfig(req.cookies.username);
|
||||||
return {resources: resources, instances: instances};
|
return {resources: resources, instances: user.instances, nodes: user.nodes};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllocatedResources (req, username) {
|
async function getAllocatedResources (req, username) {
|
||||||
|
Loading…
Reference in New Issue
Block a user