diff --git a/cloudron.js b/cloudron.js index e7778f0..5888345 100644 --- a/cloudron.js +++ b/cloudron.js @@ -799,3 +799,11 @@ Cloudron.prototype.checkNginxRateLimit = function (owner, times, callback) { }); }; +Cloudron.prototype.setAppstoreConfig = function (email, password, callback) { + superagent.post(process.env.APPSTORE_API_ORIGIN + '/api/v1/login').send({ email: email, password: password, persistent: true }).end(function (error, result) { + if (error || result.statusCode !== 200) return callback('Error logging into appstore:' + error.message); + + superagent.post('https://' + that._adminFqdn + '/api/v1/settings/appstore_config').send({ userId: result.userId, token: result.accessToken }).end(callback); + }); +}; + diff --git a/test/selfhost-digitalocean-filesystem-test.js b/test/selfhost-digitalocean-filesystem-test.js index d88ed6e..1c4f19c 100644 --- a/test/selfhost-digitalocean-filesystem-test.js +++ b/test/selfhost-digitalocean-filesystem-test.js @@ -238,6 +238,10 @@ describe('Selfhost DigitalOcean with filesystem backend', function () { cloudron.checkAddons(cloudron.appFqdn(location), owner); }); + it('can set appstore config', function (done) { + cloudron.setAppstoreConfig(process.env.APPSTORE_USERNAME, process.env.APPSTORE_PASSWORD, done); + }); + it('can update the box', function () { cloudron.checkForUpdates();