debug the html should the redirectUrl detection fail

This commit is contained in:
Girish Ramakrishnan 2015-07-27 12:41:14 -07:00
parent b19d5a1d66
commit de990f0765
1 changed files with 6 additions and 1 deletions

View File

@ -41,7 +41,12 @@ Cloudron.prototype.getOauthToken = function (user) {
var sessionCookies = res.headers['set-cookie']; // always an array
///////// should get redirected to login form with a script tag (to workaround chrome issue with redirects+cookies)
var urlp = url.parse(res.text.match(/window.location.href = "(.*)"/)[1]);
var redirectUrl = res.text.match(/window.location.href = "(.*)"/);
if (!redirectUrl) {
debug('Could not determine redirected url', res.text);
assert(false);
}
var urlp = url.parse(redirectUrl[1]);
////////// get the login form (api/v1/session/login)
res = request.get(this._origin + urlp.pathname).set('cookie', sessionCookies[0]).query(urlp.query).end();