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

[feathers-hooks-common][Bug] PreventChanges hook prevents only last defined field #2692

Closed
zaheraldefai opened this issue Jul 16, 2022 · 2 comments

Comments

@zaheraldefai
Copy link

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
Author

Have created an PR for this bug: feathersjs-ecosystem/feathers-hooks-common#680

PS: Happy to contribute to this wonderful project

@daffl
Copy link
Member

daffl commented Jul 17, 2022

Great, thank you for the pull request! Closing this issue since it is now tracked in https://github.com/feathersjs-ecosystem/feathers-hooks-common/

@daffl daffl closed this as completed Jul 17, 2022
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

2 participants