Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] PreventChanges hook prevents only last defined field #679

Closed
zaheraldefai opened this issue Jul 16, 2022 · 1 comment
Closed

[Bug] PreventChanges hook prevents only last defined field #679

zaheraldefai opened this issue Jul 16, 2022 · 1 comment

Comments

@zaheraldefai
Copy link
Contributor

zaheraldefai commented Jul 16, 2022

In case of using the preventChanges hook without wanting to throw an error, then it will only remove the last defined field from the context.data.

Example

context.data => {id: '1234', email: 'test@test.com', username: 'testuser'}

preventChanges(false, 'id', 'email')

Actual result:
context.data => {id: '1234', username: 'testuser'}

Expected result:
context.data => {username: 'testuser'}

Root issue

The data variable on line 25 is never changed and on line 33 it is always used to bring context.data to the origin state except the field of the current loop. Therefore, just the field of the last loop is removed from the context.data.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):
"@feathersjs/feathers": "^4.5.15",
"feathers-hooks-common": "^6.1.3",
"lodash": "^4.17.21",
"typescript": "^4.7.4",

NodeJS version:
Node 16

@zaheraldefai
Copy link
Contributor Author

I just saw the "Report a bug" doc and there stands that we need to create issues in the Issue-Tracker of feathersjs/feathers repository. Therefore, I have included it there: feathersjs/feathers#2692

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant