Q.ninvoke(this.request, 'post', { url: Workflowy.urls.newAuth, form: { email: this.username, password: this.password || '', code: this.code || '', } }) .then(utils.httpAbove299toError) .then(arg => { var body = arg[1] if (/Please enter a correct username and password./.test(body)) { return Q.reject({status: 403, message: "Incorrect login info"}) } }).then(arg => { var jar = this.jar._jar.toJSON() for (c in jar.cookies) { if (jar.cookies[c].key === 'sessionid') { this.sessionid = jar.cookies[c].value break } } }, err => Q.reject(err))