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 }}
Repository navigation
enhance context passing in OWNER role resolver #3250
With the move to explicit context passing of an options object, internal calls to find etc needed to be updated to pass the necessary information along, too. In this case, isOwner calls findById on a Model, but does not pass an access token in options.
In #3230, @bajtos fixed the content of passed options to {accessToken: context.accessToken} (see here whereas a way to customize the passed options is generally available (see doc)
But what if a user wants extra customization on top of that to get extra parameters in the passed options? An extreme solution could be for the developer to override the whole Role model to specify his own way of registering the role resolver, but we can probably provide an easier way of customizing the passed options.
NOTE: We should also address other internal calls of built-in CRUD methods that would require passing options.
One option is to add a new Role method to build the "options" object passed to Role.isOwner. Subclassed models then can override this method, although I am not sure how easy it is to configure LoopBack app to use own Role model.
Another option that comes to my mind is to add support for 4-arg role resolvers with the signature (role, context, options, callback). The catch is how to support promise-based resolvers and distinguish between (role, context, callback) and (role, context, options)?
still thinking about this. For the record in #2957 i chose to use a method that can be overriden, as you suggest in your first proposition.
I think it should be rather easy for a user to use a custom Role or ACL model i personally did this a couple of time with no pb.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.
Activity
bajtos commentedon Mar 6, 2017
One option is to add a new
Rolemethod to build the "options" object passed toRole.isOwner. Subclassed models then can override this method, although I am not sure how easy it is to configure LoopBack app to use ownRolemodel.Another option that comes to my mind is to add support for 4-arg role resolvers with the signature
(role, context, options, callback). The catch is how to support promise-based resolvers and distinguish between(role, context, callback)and(role, context, options)?Any other ideas?
ebarault commentedon Mar 13, 2017
still thinking about this. For the record in #2957 i chose to use a method that can be overriden, as you suggest in your first proposition.
I think it should be rather easy for a user to use a custom Role or ACL model i personally did this a couple of time with no pb.
stale commentedon Aug 23, 2017
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Sep 6, 2017
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the
CODEOWNERSfile at the top-level of this repository.