You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 22, 2022. It is now read-only.
Problem:
In many cases, the determination of an "owner" relationship between a user and a record can not be just pinned down by checking on a foreign key on the user model (e.g. everything depending on n:m relations).
Suggestion:
Introduce something like an resolveOwner field, which references a function that returns a Promise that either gets resolved (permission granted) or rejected (permission denied).
I'd gladly send a PR if you're interested, but I just wanted to check if there's already some (established) way of achieving that kind of behavior and, more importantly, how you guys think about this kind of approach.
The text was updated successfully, but these errors were encountered:
lukasbuenger
changed the title
restrictToRoles hook: More complex determination of "owner".
restrictToRoles hook: More complex determination of "owner".
May 17, 2016
I agree. I've created an issue for you to pass a callback to do whatever you want (#210) however in the mean time you can also just write your own hook to do any custom resolving.
We actually came up with a better solution. You can simply wrap any existing hooks in your own, like so:
import{hooks}from'feathers-authentication';exports.hashPassword=function(options){// Add any custom optionsfunction(hook){returnnewPromise((resolve,reject)=>{if(myCondition!==true){returnresolve(hook);}// call the original hookhooks.hashPassword(options)(hook).then(hook=>{// do something customresolve(hook);}).catch(error=>{// do any custom error handlingerror.message='my custom message';reject(error);});});});}
This provides the ultimate flexibility and doesn't require a change to the core hooks.
Problem:
In many cases, the determination of an "owner" relationship between a user and a record can not be just pinned down by checking on a foreign key on the user model (e.g. everything depending on n:m relations).
Suggestion:
Introduce something like an
resolveOwner
field, which references a function that returns a Promise that either gets resolved (permission granted) or rejected (permission denied).I'd gladly send a PR if you're interested, but I just wanted to check if there's already some (established) way of achieving that kind of behavior and, more importantly, how you guys think about this kind of approach.
The text was updated successfully, but these errors were encountered: