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

Able to get posts that belong to another user #31

Open
josecarballosa opened this issue Jul 3, 2020 · 1 comment
Open

Able to get posts that belong to another user #31

josecarballosa opened this issue Jul 3, 2020 · 1 comment

Comments

@josecarballosa
Copy link

given: "users": [ {"id": 1}, {"id": 2} ], "posts": [ {"id": 1, "text": "hello", "userId": 1}, {"id": 2, "text": "world", "userId": 2}] and
access token: xxx.xxx.xxx for user id:1
when: curl -H "Authorization: Bearer xxx.xxx.xxx" http://localhost:3000/600/posts
expect: only [ { "id": 1, "text": "hello", "userId": 1} ]
actual: [ { "id": 1, "text": "hello", "userId": 1}, {"id": 2, "text": "world", "userId": 2} ]

@sulthanprovab
Copy link

sulthanprovab commented Aug 12, 2021

Hi @carballosa

I am new to json-server-auth module

But I tried about "your query " and locally fixed this with the following

node_modules\json-server-auth\dist\guards.js

added the following line ( need to add userId in queryString )


if (hasRightUserId) {
    req.query.userId = req.claims.sub; /* need to add userId in queryString */
    next();
} else {
    res.status(403).jsonp('Private resource access: entity must have a reference to the owner id');
}


Please let me know if anything...

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

No branches or pull requests

2 participants