assert if csrf could not be found

This commit is contained in:
girish@cloudron.io 2016-02-25 21:27:34 -08:00
parent 6189e7a6dc
commit beda8d5ece
1 changed files with 6 additions and 1 deletions

View File

@ -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);