Rework config routes
The config route now returns non-sensitive information under the profile scope. Caas config is a separate route Update config is a separate route
This commit is contained in:
@@ -134,8 +134,6 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
this.apiOrigin = '<%= oauth.apiOrigin %>' || window.location.origin;
|
||||
this.avatar = '';
|
||||
|
||||
this._refreshConfigTimer = null;
|
||||
|
||||
this.resetAvatar();
|
||||
|
||||
this.setToken(localStorage.token);
|
||||
@@ -283,9 +281,7 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
* Rest API wrappers
|
||||
*/
|
||||
Client.prototype.config = function (callback) {
|
||||
var configRoute = this.hasScope('cloudron') ? '/api/v1/cloudron/config' : '/api/v1/user/cloudron_config';
|
||||
|
||||
get(configRoute).success(function(data, status) {
|
||||
get('/api/v1/config').success(function(data, status) {
|
||||
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
||||
callback(null, data);
|
||||
}).error(defaultErrorHandler(callback));
|
||||
@@ -497,6 +493,13 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.getUpdateInfo = function (callback) {
|
||||
get('/api/v1/cloudron/update').success(function(data, status) {
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
callback(null, data);
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.checkForUpdates = function (callback) {
|
||||
var that = this;
|
||||
|
||||
@@ -550,6 +553,13 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.getCaasConfig = function (callback) {
|
||||
get('/api/v1/caas/config').success(function(data, status) {
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
callback(null, data);
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.addAuthorizedKey = function (key, callback) {
|
||||
put('/api/v1/cloudron/ssh/authorized_keys', { key: key }).success(function (data, status) {
|
||||
if (status !== 201) return callback(new ClientError(status, data));
|
||||
@@ -971,6 +981,17 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.transferOwnership = function (oldOwnerId, newOwnerId, callback) {
|
||||
var data = {
|
||||
ownerId: newOwnerId
|
||||
};
|
||||
|
||||
post('/api/v1/users/' + oldOwnerId + '/transfer', data).success(function (data, status) {
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
callback(null);
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.removeUser = function (userId, password, callback) {
|
||||
var config = {
|
||||
data: {
|
||||
@@ -1058,9 +1079,12 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
this.config(function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
that.setConfig(result);
|
||||
that.getUpdateInfo(function (error, info) { // note: non-admin users may get access denied for this
|
||||
if (!error) result.update = info.update; // attach update information to config object
|
||||
|
||||
callback(null);
|
||||
that.setConfig(result);
|
||||
callback(null);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user