diff --git a/cloudron.js b/cloudron.js index ee968ad..8deb997 100644 --- a/cloudron.js +++ b/cloudron.js @@ -50,7 +50,12 @@ Cloudron.prototype.getOauthToken = function (user) { ////////// get the login form (api/v1/session/login) res = request.get(this._origin + urlp.pathname).set('cookie', sessionCookies[0]).query(urlp.query).end(); - var csrf = res.text.match(/name="_csrf" value="(.*)"/)[1]; + var csrfs = res.text.match(/name="_csrf" value="(.*)"/); + if (!csrfs) { + debug('Could not determine csrf', res.text, res.headers); + assert(false); + } + var csrf = csrfs[1]; sessionCookies = res.headers['set-cookie']; // always an array assert.notStrictEqual(sessionCookies.length, 0);