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:
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user