rework code to enable/disable remote support

we had a generic ssh key management api. this was causing issues because
the ssh format is more complicated than what we had implemented. currently,
the only use case we have is to add our ssh key.

Fixes #600
This commit is contained in:
Girish Ramakrishnan
2018-12-19 11:47:15 -08:00
parent a8d9b57c47
commit 4a34703cd3
13 changed files with 281 additions and 499 deletions

View File

@@ -1,7 +1,10 @@
'use strict';
exports = module.exports = {
feedback: feedback
feedback: feedback,
getRemoteSupport: getRemoteSupport,
enableRemoteSupport: enableRemoteSupport
};
var appstore = require('../appstore.js'),
@@ -9,6 +12,7 @@ var appstore = require('../appstore.js'),
assert = require('assert'),
HttpError = require('connect-lastmile').HttpError,
HttpSuccess = require('connect-lastmile').HttpSuccess,
support = require('../support.js'),
_ = require('underscore');
function feedback(req, res, next) {
@@ -29,3 +33,23 @@ function feedback(req, res, next) {
next(new HttpSuccess(201, {}));
});
}
function enableRemoteSupport(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.enable !== 'boolean') return next(new HttpError(400, 'enabled is required'));
support.enableRemoteSupport(req.body.enable, function (error) {
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(202, {}));
});
}
function getRemoteSupport(req, res, next) {
support.getRemoteSupport(function (error, status) {
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, status));
});
}