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

Make default scope overridable #3279

Closed
smyth64 opened this issue Mar 14, 2017 · 1 comment
Closed

Make default scope overridable #3279

smyth64 opened this issue Mar 14, 2017 · 1 comment
Labels

Comments

@smyth64
Copy link

smyth64 commented Mar 14, 2017

Hey there!

Description/Steps to reproduce

I just created a model and also a default scope for its relation:

Mother.json

  "scope": {
    "include": [
      {
        "relation": "children"
      },
    ]
  }

When I do a normal query at /api/mother I get all children. Fine.

But when I try this:

/api/mother/?filter={"include": [ { "relation": "children", "scope": { "name": "Barney" } } ] }

I still get all children.
When I remove the default scope, my query works.

Expected result

It would be really nice, if the default scope for "children" gets overridden, if I provide a custom scope in my query.

Additional information

I hope you understand what I mean :)

👍 👍 👍 LOOPBACK IS AWESOME!!!

@ebarault
Copy link
Contributor

hi @smith64fx, this is related to datasource-juggler

For track record, see this existing (though outdated) PR: #787

the overall rationale is the following:
for security reasons, it should not be possible to override a scope to make it more open

in your specific case though the rationale does not apply as you narrow the scope.

👉 first of all, check your code: you are missing a where clause in your scope:

should be

"include": [ { "relation": "children", "scope": { where: { "name": "Barney" } } } ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants