rjz / supertest-session

Persistent sessions for supertest
Other
88 stars 21 forks source link

having the same issue #52

Closed ahmadbingulzar closed 1 year ago

ahmadbingulzar commented 1 year ago

getting XSRF-TOKEN successfully but when i try to login it shows XSRF-TOKEN mismatch also it is working preety fine on browsers and postman**

`const app = require('../../../app.js'); const expect = require('chai').expect; const request = require('supertest'); var csrfToken;

describe('GET /api/csrf-token', () => { it('OK, Getting CSRF Token', (done) => { request(app).get('/api/csrf-token') .expect(200) .then((res) => { const body = res.body; csrfToken=body.csrfToken; expect(body).to.contain.property('csrfToken'); done(); }) .catch((err) => done(err)); }); });

describe('POST /api/users/login', () => { it('OK, Logging in with super admin crediantials', (done) => { request(app).post('/api/users/login') .set('Content-Type', 'application/json') .set("Accept","/") .set("XSRF-TOKEN",csrfToken) .set("Cookie","XSRF-TOKEN",csrfToken) .set("withCredentials",true) .expect(200) .send({"email":"super@abc.com","password":"abc"}) .expect((res) => { const body = res.body; console.log(body); expect(body.message).to.contain.property('Auth Successful'); expect(body).to.contain.property('token'); done(); }) .catch((err) => done(err)); }); }); `

Originally posted by @ahmadbingulzar in https://github.com/rjz/supertest-session/issues/32#issuecomment-1293623163

ahmadbingulzar commented 1 year ago

Issue Resolved if someone facing the same issue feel free to contact at ahmadbingulzar@gmail.com