fix bugs in utils.js

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-05-24 22:42:38 +00:00
parent 0ad242a557
commit 52d40796e9

View File

@ -42,15 +42,12 @@ export async function approveResources(req, username, request) {
let avail = (await getUserResources(req, username)).avail;
Object.keys(request).forEach((key) => {
if (!(key in avail)) { // if requested resource is not in avail, block
approved = false;
return false;
}
else if (isNaN(avail[key]) || isNaN(request[key])) { // if either the requested or avail resource is NaN, block
approved = false;
return false;
}
else if (avail[key] - request[key] < 0) { // if the avail resources is less than the requested resources, block
approved = false;
return false;
}
});