fix bug in input validation

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-03-24 22:22:00 +00:00
parent f34d9ae523
commit 6bda62ae15

4
db.js
View File

@ -45,7 +45,7 @@ function allocateResources (user, resources) {
let newdb = {};
Object.assign(newdb, db);
Object.keys(resources).forEach((element) => {
if(resources[element] instanceof Number && isFinite(resources[element])) {
if(typeof(resources[element]) === "number" && isFinite(resources[element])) {
newdb[user][element] -= resources[element];
}
else {
@ -73,7 +73,7 @@ function releaseResources (user, resources) {
let newdb = {};
Object.assign(newdb, db);
Object.keys(resources).forEach((element) => {
if(resources[element] instanceof Number && isFinite(resources[element]) && resources[element]) {
if(typeof(resources[element]) === "number" && isFinite(resources[element]) && resources[element]) {
newdb[user][element] += resources[element];
}
else {