Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
daffl merged 1 commit intofeathersjs-ecosystem:masterfeathersjs-ecosystem/feathers-sequelize:masterfrom
evanbarter:masterCopy head branch name to clipboard
Jan 9, 2016
Merged

Use Model.findById() rather than get()#7
daffl merged 1 commit intofeathersjs-ecosystem:masterfeathersjs-ecosystem/feathers-sequelize:masterfrom
evanbarter:masterCopy head branch name to clipboard

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.