mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix: pass csrf_token into calls to /register/abort, #11017
This commit is contained in:
@@ -485,7 +485,7 @@ describe('API', async () => {
|
|||||||
const affectedPaths = ['GET /api/user/{userslug}/edit/email'];
|
const affectedPaths = ['GET /api/user/{userslug}/edit/email'];
|
||||||
if (affectedPaths.includes(`${method.toUpperCase()} ${path}`)) {
|
if (affectedPaths.includes(`${method.toUpperCase()} ${path}`)) {
|
||||||
await request({
|
await request({
|
||||||
uri: `${nconf.get('url')}/register/abort`,
|
uri: `${nconf.get('url')}/register/abort?_csrf=${csrfToken}`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
jar,
|
jar,
|
||||||
simple: false,
|
simple: false,
|
||||||
|
|||||||
@@ -1237,8 +1237,10 @@ describe('Controllers', () => {
|
|||||||
|
|
||||||
describe('account pages', () => {
|
describe('account pages', () => {
|
||||||
let jar;
|
let jar;
|
||||||
|
let csrf_token;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
({ jar } = await helpers.loginUser('foo', 'barbar'));
|
({ jar, csrf_token } = await helpers.loginUser('foo', 'barbar'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should redirect to account page with logged in user', (done) => {
|
it('should redirect to account page with logged in user', (done) => {
|
||||||
@@ -1802,7 +1804,7 @@ describe('Controllers', () => {
|
|||||||
assert.strictEqual(res.body, '/register/complete');
|
assert.strictEqual(res.body, '/register/complete');
|
||||||
|
|
||||||
await requestAsync({
|
await requestAsync({
|
||||||
uri: `${nconf.get('url')}/register/abort`,
|
uri: `${nconf.get('url')}/register/abort?_csrf=${csrf_token}`,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
jar,
|
jar,
|
||||||
simple: false,
|
simple: false,
|
||||||
|
|||||||
@@ -814,6 +814,7 @@ describe('User', () => {
|
|||||||
describe('profile methods', () => {
|
describe('profile methods', () => {
|
||||||
let uid;
|
let uid;
|
||||||
let jar;
|
let jar;
|
||||||
|
let csrf_token;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const newUid = await User.create({ username: 'updateprofile', email: 'update@me.com', password: '123456' });
|
const newUid = await User.create({ username: 'updateprofile', email: 'update@me.com', password: '123456' });
|
||||||
@@ -822,7 +823,7 @@ describe('User', () => {
|
|||||||
await User.setUserField(uid, 'email', 'update@me.com');
|
await User.setUserField(uid, 'email', 'update@me.com');
|
||||||
await User.email.confirmByUid(uid);
|
await User.email.confirmByUid(uid);
|
||||||
|
|
||||||
({ jar } = await helpers.loginUser('updateprofile', '123456'));
|
({ jar, csrf_token } = await helpers.loginUser('updateprofile', '123456'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return error if not logged in', async () => {
|
it('should return error if not logged in', async () => {
|
||||||
@@ -1287,7 +1288,7 @@ describe('User', () => {
|
|||||||
|
|
||||||
// Accessing this page will mark the user's account as needing an updated email, below code undo's.
|
// Accessing this page will mark the user's account as needing an updated email, below code undo's.
|
||||||
await requestAsync({
|
await requestAsync({
|
||||||
uri: `${nconf.get('url')}/register/abort`,
|
uri: `${nconf.get('url')}/register/abort?_csrf=${csrf_token}`,
|
||||||
jar,
|
jar,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
simple: false,
|
simple: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user