Added confirmation page for monitoring + a few tweaks.
This commit is contained in:
parent
1b173b79d4
commit
0bdce5debb
24 changed files with 431 additions and 72 deletions
server/services
30
server/services/monitoringService.js
Normal file
30
server/services/monitoringService.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffng')
|
||||
.service('MonitoringService', function (NodeService, ErrorTypes) {
|
||||
return {
|
||||
confirm: function (mac, token, callback) {
|
||||
NodeService.getNodeDataByMac(mac, function (err, node, nodeSecrets) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!node.monitoring || !nodeSecrets.monitoringToken || nodeSecrets.monitoringToken !== token) {
|
||||
return callback({data: 'Invalid token.', type: ErrorTypes.badRequest});
|
||||
}
|
||||
|
||||
if (node.monitoringConfirmed) {
|
||||
return callback(null, node);
|
||||
}
|
||||
|
||||
node.monitoringConfirmed = true;
|
||||
NodeService.internalUpdateNode(node.token, node, nodeSecrets, function (err, token, node) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, node);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue