add node restriction
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
0063b6b2b9
commit
2a70548a43
5
main.js
5
main.js
@ -229,6 +229,11 @@ app.post("/api/instance", async (req, res) => {
|
||||
res.end();
|
||||
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 = {
|
||||
vmid: req.body.vmid,
|
||||
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) {
|
||||
let resources = await getAllocatedResources(req, username);
|
||||
let instances = getUserConfig(req.cookies.username).instances;
|
||||
return {resources: resources, instances: instances};
|
||||
let user = getUserConfig(req.cookies.username);
|
||||
return {resources: resources, instances: user.instances, nodes: user.nodes};
|
||||
}
|
||||
|
||||
async function getAllocatedResources (req, username) {
|
||||
|
Loading…
Reference in New Issue
Block a user