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

Use Model.findById() rather than get() #7

Merged
merged 1 commit into from
Jan 9, 2016
Merged

Use Model.findById() rather than get() #7

merged 1 commit into from
Jan 9, 2016

Conversation

evanbarter
Copy link
Contributor

Calling this.get() from within remove() will not populate params.user object, and if you have a before get hook validating the presence of a user object (i.e. feathers-authentication.hooks.requireAuth) it will throw an error.

This is a bit of a weird situation because of some inconsistencies in the API. update() takes an id and Model.findById() is used so I guess the assumption is the author will validate access, permissions etc in a before update hook. patch() takes an id or params but ultimately does a find and passes the id in to the params.where object, if present.

This PR follows the update() method of retrieving a single instance for remove().

@daffl
Copy link
Member

daffl commented Jan 9, 2016

Thank you. You are right, that behaviour is indeed inconsistent. I also noticed that passing on to find will cause issues when pagination is enabled so I'll do another review before getting this change out in a patch release.

daffl added a commit that referenced this pull request Jan 9, 2016
Use Model.findById() rather than get()
@daffl daffl merged commit 7656fd4 into feathersjs-ecosystem:master Jan 9, 2016
@daffl
Copy link
Member

daffl commented Jan 9, 2016

Thanks again. I made a 1.0.8 patch release with your fix and created a follow-up issue to review the consistency of that part of the API.

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

Successfully merging this pull request may close these issues.

2 participants