From beda8d5ece5b87fbe7b12536d60f4355f601ee00 Mon Sep 17 00:00:00 2001 From: "girish@cloudron.io" Date: Thu, 25 Feb 2016 21:27:34 -0800 Subject: [PATCH] assert if csrf could not be found --- cloudron.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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);