use appstore.login
This commit is contained in:
parent
d545ae7134
commit
728b12f866
@ -24,7 +24,7 @@ function AppStore(origin) {
|
||||
}
|
||||
|
||||
AppStore.prototype.getAccessToken = function (user) {
|
||||
var res = request.get(this._origin + '/api/v1/login').auth(user.email, user.password).end();
|
||||
var res = request.post(this._origin + '/api/v1/login').send({ email: user.email, password: user.password, persistent: true }).end();
|
||||
common.verifyResponse2xx(res, 'Could not login as user:' + user.email + ' password:' + user.password);
|
||||
return res.body.accessToken;
|
||||
};
|
||||
|
@ -799,11 +799,8 @@ 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);
|
||||
});
|
||||
Cloudron.prototype.setAppstoreConfig = function (id, token, callback) {
|
||||
var res = request.post('https://' + that._adminFqdn + '/api/v1/settings/appstore_config').send({ userId: id, token: token }).end();
|
||||
common.verifyResponse2xx(res, 'Could not set appstore config');
|
||||
};
|
||||
|
||||
|
@ -239,7 +239,11 @@ describe('Selfhost DigitalOcean with filesystem backend', function () {
|
||||
});
|
||||
|
||||
it('can set appstore config', function (done) {
|
||||
cloudron.setAppstoreConfig(process.env.APPSTORE_USERNAME, process.env.APPSTORE_PASSWORD, done);
|
||||
var token = appStore.getAccessToken(owner);
|
||||
appStore.setCredentials(owner.password, token);
|
||||
var profile = appStore.getProfile();
|
||||
console.dir(profile);
|
||||
cloudron.setAppstoreConfig(profile.id, token);
|
||||
});
|
||||
|
||||
it('can update the box', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user