From a47193e9fd036804d29b03f10d996267cc70fa2a Mon Sep 17 00:00:00 2001 From: Nicola Peditto Date: Thu, 2 Aug 2018 14:45:39 +0200 Subject: [PATCH] v2.2.0: fix some bugs --- lib/management/mng_auth.js | 1 + lib/management/mng_board.js | 16 ++++++++++++---- lib/management/mng_db.js | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/management/mng_auth.js b/lib/management/mng_auth.js index 7e3be9a..d1da1ab 100644 --- a/lib/management/mng_auth.js +++ b/lib/management/mng_auth.js @@ -600,6 +600,7 @@ var computeCredentials = function (b_pw, b_pub_key, callback) { response.message = "credentials"; response.result = "SUCCESS"; response.hash_pw = pw_result.message; + response.gen_pw = gen_pw; callback(response); } diff --git a/lib/management/mng_board.js b/lib/management/mng_board.js index 0b48389..da1b8d5 100644 --- a/lib/management/mng_board.js +++ b/lib/management/mng_board.js @@ -522,6 +522,8 @@ board_utils = function (session, rest) { var hash_b_pw = credentials.hash_pw; var b_pub_key = credentials.pub_key; + console.log(credentials); + db.regBoard(board_id, board_label, latitude, longitude, altitude, net_enabled, sensorslist, layout_id, description, extra, project_id, user_id, mobile, position_refr_time, notify, notify_rate, notify_retry, b_pub_key, hash_b_pw, @@ -530,7 +532,10 @@ board_utils = function (session, rest) { if (db_result.result === "SUCCESS") { logger.info("[SYSTEM] --> Registration of board '" + board_id + "' successfully completed!"); - db_result.password = b_pw; + if(b_pw == "" || b_pw == undefined){ + db_result.password = credentials.gen_pw; + }else + db_result.password = b_pw; res.status(200).send(db_result); @@ -792,7 +797,9 @@ board_utils = function (session, rest) { var localISOTime = (new Date(Date.now() - tzoffset)).toISOString(); position.timestamp=localISOTime; - session.call('s4t.' + board + '.board.setBoardPosition', [position]).then( + console.log("position @ " + position.timestamp); + + session_wamp.call('s4t.' + board + '.board.setBoardPosition', [position]).then( function (conf_result) { response.message = db_result.message + " - " + conf_result; @@ -2319,7 +2326,7 @@ var addBoardPosition = function (board, latitude, longitude, altitude, res){ logger.debug("--> Board "+available.message.label+" (" + board + ") exists!"); - if (available.message.mobile == 1){ + //if (available.message.mobile == 1){ db.addBoardPosition(board, latitude, longitude, altitude, function (data) { @@ -2341,7 +2348,7 @@ var addBoardPosition = function (board, latitude, longitude, altitude, res){ }); - +/* }else{ response.result = "WARNING"; @@ -2350,6 +2357,7 @@ var addBoardPosition = function (board, latitude, longitude, altitude, res){ res.status(200).send(response); } + */ diff --git a/lib/management/mng_db.js b/lib/management/mng_db.js index a2fe852..fa44b23 100644 --- a/lib/management/mng_db.js +++ b/lib/management/mng_db.js @@ -571,7 +571,7 @@ db_utils.prototype.regBoard = function (board, board_label, latitude, longitude, } else { response.result = "WARNING"; - response.message = "The board " + board_label + " ("+board+") already exists!"; + response.message = "A board with ID '"+board+"' already exists!"; logger.warn("[SYSTEM] ----> " + response.message); disconn(connection); callback(response);