prepare to async: stricter checks

This change is in preparation of the future async refactoring by Ray. It tries
to extract as many changes in boolean conditions as possible, in order to make
more evident identifying eventual logic bugs in the future work.

This proved already useful in at least one case.

BEWARE: this commit exposes an incoherency in the DB API, in which, depending
on the driver used, some functions can return null or undefined. This condition
will be externally fixed by the final commit in this series ("db/DB.js: prevent
DB layer from returning undefined"). Until that commit, the code base may have
some bugs.
This commit is contained in:
muxator 2019-03-01 09:43:41 +01:00
parent e841798314
commit 11453d544c
7 changed files with 36 additions and 36 deletions

View file

@ -188,7 +188,7 @@ exports.handle = function(apiVersion, functionName, fields, req, res)
// check the api key!
fields["apikey"] = fields["apikey"] || fields["api_key"];
if (fields["apikey"] != apikey.trim()) {
if (fields["apikey"] !== apikey.trim()) {
res.statusCode = 401;
res.send({code: 4, message: "no or wrong API Key", data: null});
return;

View file

@ -95,7 +95,7 @@ exports.setSocketIO = function(_socket) {
var checkAccessCallback = function(err, statusObject) {
ERR(err);
if (statusObject.accessStatus == "grant") {
if (statusObject.accessStatus === "grant") {
// access was granted, mark the client as authorized and handle the message
clientAuthorized = true;
handleMessage(client, message);