diff --git a/src/js/client.js b/src/js/client.js index 895ebb315..466c6ff64 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -630,17 +630,17 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N }); }; - Client.prototype.addAuthorizedKey = function (key, callback) { - put('/api/v1/cloudron/ssh/authorized_keys', { key: key }, null, function (error, data, status) { + Client.prototype.getRemoteSupport = function (callback) { + get('/api/v1/support/remote_support', null, function (error, data, status) { if (error) return callback(error); - if (status !== 201) return callback(new ClientError(status, data)); + if (status !== 200) return callback(new ClientError(status, data)); - callback(null); + callback(null, data.enabled); }); }; - Client.prototype.delAuthorizedKey = function (identifier, callback) { - del('/api/v1/cloudron/ssh/authorized_keys/' + identifier, null, function (error, data, status) { + Client.prototype.enableRemoteSupport = function (enable, callback) { + post('/api/v1/support/remote_support', { enable: enable }, null, function (error, data, status) { if (error) return callback(error); if (status !== 202) return callback(new ClientError(status, data)); @@ -648,15 +648,6 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N }); }; - Client.prototype.getAuthorizedKeys = function (callback) { - get('/api/v1/cloudron/ssh/authorized_keys', null, function (error, data, status) { - if (error) return callback(error); - if (status !== 200) return callback(new ClientError(status, data)); - - callback(null, data.keys); - }); - }; - Client.prototype.getBackups = function (callback) { get('/api/v1/backups', null, function (error, data, status) { if (error) return callback(error); diff --git a/src/views/support.js b/src/views/support.js index 6c795861a..50255c360 100644 --- a/src/views/support.js +++ b/src/views/support.js @@ -46,30 +46,21 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat }); }; - var CLOUDRON_SUPPORT_PUBLIC_KEY = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQVilclYAIu+ioDp/sgzzFz6YU0hPcRYY7ze/LiF/lC7uQqK062O54BFXTvQ3ehtFZCx3bNckjlT2e6gB8Qq07OM66De4/S/g+HJW4TReY2ppSPMVNag0TNGxDzVH8pPHOysAm33LqT2b6L/wEXwC6zWFXhOhHjcMqXvi8Ejaj20H1HVVcf/j8qs5Thkp9nAaFTgQTPu8pgwD8wDeYX1hc9d0PYGesTADvo6HF4hLEoEnefLw7PaStEbzk2fD3j7/g5r5HcgQQXBe74xYZ/1gWOX2pFNuRYOBSEIrNfJEjFJsqk3NR1+ZoMGK7j+AZBR4k0xbrmncQLcQzl6MMDzkp support@cloudron.io'; - var CLOUDRON_SUPPORT_PUBLIC_KEY_IDENTIFIER = 'support@cloudron.io'; - $scope.toggleSshSupport = function () { - if ($scope.sshSupportEnabled) { - Client.delAuthorizedKey(CLOUDRON_SUPPORT_PUBLIC_KEY_IDENTIFIER, function (error) { - if (error) return console.error(error); - $scope.sshSupportEnabled = false; - }); - } else { - Client.addAuthorizedKey(CLOUDRON_SUPPORT_PUBLIC_KEY, function (error) { - if (error) return console.error(error); - $scope.sshSupportEnabled = true; - }); - } + Client.enableRemoteSupport(!$scope.sshSupportEnabled, function (error) { + if (error) return $scope.error(error); + + $scope.sshSupportEnabled = !$scope.sshSupportEnabled; + }); }; Client.onReady(function () { if ($scope.config.managed) return; - Client.getAuthorizedKeys(function (error, keys) { + Client.getRemoteSupport(function (error, enabled) { if (error) return console.error(error); - $scope.sshSupportEnabled = keys.some(function (k) { return k.key === CLOUDRON_SUPPORT_PUBLIC_KEY; }); + $scope.sshSupportEnabled = enabled; }); });