Verify the appstore details and register the cloudron with the store

This commit is contained in:
Johannes Zellner
2016-08-01 13:08:05 +02:00
parent f60ff45cb6
commit aedd370e76
2 changed files with 61 additions and 1 deletions

View File

@@ -151,5 +151,20 @@ angular.module('Application').service('AppStore', ['$http', '$base64', 'Client',
});
};
AppStore.prototype.registerCloudron = function (token, userId, fqdn, callback) {
if (Client.getConfig().apiServerOrigin === null) return callback(new AppStoreError(420, 'Enhance Your Calm'));
var data = {
domain: fqdn
};
$http.post(Client.getConfig().apiServerOrigin + '/api/v1/users/' + userId + '/cloudrons', data, { params: { accessToken: token }}).success(function (data, status) {
if (status !== 201) return callback(new AppStoreError(status, data));
return callback(null, data.cloudron);
}).error(function (data, status) {
return callback(new AppStoreError(status, data));
});
};
return new AppStore();
}]);