This commit is contained in:
Girish Ramakrishnan 2015-12-17 20:58:50 -08:00
parent 070f99ea84
commit 7419471db2

View File

@ -18,7 +18,8 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
function Cloudron(box) {
this._box = box;
this._origin = box.domain === process.env.CUSTOM_DOMAIN ? 'https://my.' + box.domain : 'https://my-' + box.domain;
this._isCustomDomain = box.domain === process.env.CUSTOM_DOMAIN;
this._origin = this._isCustomDomain ? 'https://my.' + box.domain : 'https://my-' + box.domain;
this._credentials = {
password: null,
@ -26,6 +27,10 @@ function Cloudron(box) {
};
}
Cloudron.prototype.appFqdn = function (location) {
return location + (this._isCustomDomain ? '.' : '-') + this._box.domain;
};
// get oauth token for logged in as certain user { username, password, email }
Cloudron.prototype.getOauthToken = function (user) {
var username = user.username;
@ -313,7 +318,7 @@ Cloudron.prototype.checkAddons = function (location, owner) {
// try many times because the scheduler takes sometime to run
for (var i = 0; i < 100; i++) {
var res = request.post('https://' + location + '-' + this._box.domain + '/check_addons').query({ username: owner.username, password: owner.password }).end();
var res = request.post('https://' + this.appFqdn(location) + '/check_addons').query({ username: owner.username, password: owner.password }).end();
try {
assert.strictEqual(res.statusCode, 200);