-
Notifications
You must be signed in to change notification settings - Fork 89
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
Using iff with restrictToOwner #140
Comments
… On Fri, Mar 10, 2017 at 5:41 AM, Maik Hummel ***@***.***> wrote:
Steps to reproduce
const auth = require('feathers-authentication').hooksconst iff = require('feathers-hooks-common').iffconst isNot = require('feathers-hooks-common').isNotconst isCortex = require('../../hooks/cortex').isCortexconst isUser = require('../../hooks/auth').isUser
exports.before = {
[...]
patch: [ isUser, iff(isNot(isCortex()), auth.restrictToOwner({ ownerField: 'id' })) ]
[...]
}
Send a patch request to the service as user ("Cortex" is the equivalent
of an admin user).
Actual behavior
TypeError: Cannot read property 'get' of undefined
File "/[...]/node_modules/feathers-authentication/lib/hooks/restrict-to-owner.js", line 47, col 19, in exports.default
return _this.get(hook.id, params).then(function (data) {
File "/[...]/node_modules/feathers-authentication/lib/hooks/restrict-to-owner.js", line 42, col 12, in exports.default
return new Promise(function (resolve, reject) {
*Module versions* (especially the part that's not working):
feathers: "2.1.1",feathers-authentication: "0.7.11",feathers-hooks: "1.8.1",feathers-hooks-common: "2.0.3"
*NodeJS version*:
Node v6.9.4
Unfortunately I could not find any reference if this kind of hook
combination should properly work this way.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#140>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABezn6SrRt7_Y6q89hHm_oKVFOdI3Wb3ks5rkSjCgaJpZM4MZO8V>
.
|
hmm... is likely an issue with the |
@ekryski Well, that's unhandy. As a temporary work-around (until feathers-permissions, etc.) are ready-to-rock, is there a simple way to replicate |
Actually @eddyystop I did notice this when using hooks. That the @beevelop so I take back my previous comment, those hooks should work with the common hooks. |
That function needs to be bound `that`. I'm out for a few hours right now.
…On Fri, Mar 10, 2017 at 12:58 PM, Eric Kryski ***@***.***> wrote:
Actually @eddyystop <https://github.com/eddyystop> I did notice this when
using hooks. That the this context was no longer set to the service. I
wonder if it is this line? https://github.com/feathersjs/
feathers-hooks-common/blob/master/src/common/iff.js#L10
@beevelop <https://github.com/beevelop> so I take back my previous
comment, those hooks *should* work with the common hooks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#140 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABeznw5xhhnvW58up6X3037wc1JOQDBsks5rkY9NgaJpZM4MZO8V>
.
|
@eddyystop @ekryski Do you mean something like this 👇 in common/iff.js: iffWithoutElse.else = (...falseHooks) => _iffElse(predicate, trueHooks, falseHooks).call(that, hook); |
Something like that. Please try it and report back. :) I'm tied up with
other Feathers things ATM.
…On Tue, Mar 21, 2017 at 12:10 PM, Maik Hummel ***@***.***> wrote:
@eddyystop <https://github.com/eddyystop> @ekryski
<https://github.com/ekryski> Do you mean something like this 👇 in
common/iff.js
<https://github.com/feathersjs/feathers-hooks-common/blob/master/src/common/iff.js#L10>
:
iffWithoutElse.else = (...falseHooks) => _iffElse(predicate, trueHooks, falseHooks).call(that, hook);
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#140 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABezn-3xA4AwxDR0q7tSsEda4NBsb0OWks5rn_ZcgaJpZM4MZO8V>
.
|
I think so. @beevelop I'm also tied up with Feathers docs right now but if you are able to write a test and create a PR I'll ❤️ you forever. 😄 |
I have spent way too long on this without success. The expected context isn't being passed to functions with I've changed the docs to say BTW we've run into other issues with Babel. #116 |
Reopen this issue if you want to take a shot at it. |
Steps to reproduce
Send a patch request to the service as
user
("Cortex" is the equivalent of an admin user).Actual behavior
Module versions (especially the part that's not working):
NodeJS version:
Unfortunately I could not find any reference if this kind of hook combination should properly work this way.
The text was updated successfully, but these errors were encountered: