handle NaN or undefined values in approveResources

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-05-18 14:58:44 +00:00
parent 754e7a018b
commit 4444416175

View File

@ -21,9 +21,12 @@ export async function approveResources(req, username, request) {
if (!(key in avail)) {
approved = false;
}
else if (avail[key] - request[key] < 0) {
else if (isNaN(avail[key]) || isNaN(request[key])) {
approved = false;
}
else if (avail[key] - request[key] < 0) {
approved = false;
}
});
return approved;
}