Fix resetting account for social accounts (#15087)

* Fix resetting account for social accounts

* added integration tests

* chore(packages): reinstall modules

* only enable reset button if user typed RESET

* fix enabling reset button

---------

Co-authored-by: negue <eugen.bolz@gmail.com>
Co-authored-by: Sabe Jones <sabe@habitica.com>
This commit is contained in:
Phillip Thelen
2024-01-18 22:51:36 +01:00
committed by GitHub
parent 67069b1adc
commit 1ade4c6b3e
7 changed files with 119 additions and 7 deletions

View File

@@ -6,6 +6,8 @@ import {
translate as t,
} from '../../../helpers/api-integration/v4';
const RESET_CONFIRMATION = 'RESET';
describe('POST /user/reset', () => {
let user;
@@ -172,4 +174,68 @@ describe('POST /user/reset', () => {
expect(heroRes.secret).to.exist;
expect(heroRes.secret.text).to.be.eq('Super-Hero');
});
context('user with Google auth', async () => {
beforeEach(async () => {
user = await generateUser({
auth: {
google: {
id: 'google-id',
},
},
});
});
it('resets a Google user', async () => {
const task = await user.post('/tasks/user', {
text: 'test habit',
type: 'habit',
});
await user.post('/user/reset', {
password: RESET_CONFIRMATION,
});
await user.sync();
await expect(user.get(`/tasks/${task._id}`)).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('messageTaskNotFound'),
});
expect(user.tasksOrder.habits).to.be.empty;
});
});
context('user with Apple auth', async () => {
beforeEach(async () => {
user = await generateUser({
auth: {
apple: {
id: 'apple-id',
},
},
});
});
it('resets an Apple user', async () => {
const task = await user.post('/tasks/user', {
text: 'test habit',
type: 'habit',
});
await user.post('/user/reset', {
password: RESET_CONFIRMATION,
});
await user.sync();
await expect(user.get(`/tasks/${task._id}`)).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('messageTaskNotFound'),
});
expect(user.tasksOrder.habits).to.be.empty;
});
});
});