-
Notifications
You must be signed in to change notification settings - Fork 2
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
Role.isInRole && ACL.isMappedToRole do not work #3
Comments
@mike-aungsan Did you try running the test in the LoopBack repo? Does it pass? |
Some of them passed. Some does not. I am also going to look into detail. test@test:~/loopback/loopback/test$ mocha role.test.js role model 5 passing (3s)
|
Can I extend RoleMapping?
role-mapping.json
role-mapping.js
role.json Here I cannot make admin Allow, acl 2nd rule, for everything. Any help?
|
Is this a confirmed bug? I am using Role.isInRole() and not getting expected results. Any workaround/fix in sight? |
Do you have a simple repo to reproduce the issue? |
Hmm I am afraid not. Commercial project I have been contracted for. I just need to know if a user is an admin. With my registered admin user, which I set up using the recommended method in the docs, when I do Role.isInRole("admin",context, callback) I always get back false. Should be true for an admin...(context is loopback.getCurrentContext()). The current workaround I have is cumbersome and not really nice, getting all RoleMapping and iterate until I found my admin user... |
Hi, |
@raymondfeng I published a simple repo to reproduce the problem. It'a vanilla loopback, with just one TestModel. there is a simple test file in test/testmodels.js, which can be executed via the simple Be sure to run npm install and npm install -g mocha Also, I had to intervene in loopback-testing in order to be able to use a user which is logged in without always creating it (I don't know why loopback testing is doing it that way, it's counter-intuitive). So you need to replace node_modules/loopback-testing/lib/helpers.js with the helpers.js in the root folder. It's just has some quick hacks in order for you to be able to reproduce this problem :) So if you successfully can get the repo to run you would always get "false" for an admin user.... The repo is at |
This work. user.json
access-token.json
role.json
role-mapping.json
|
I finally found this repo. Basically copy the code from this file
https://github.com/strongloop/loopback/blob/9a33602458712afecedd25062f02bd8b5c4e01a5/test/role.test.js
Those two functions does not work. isInRole should be true
Mongodb
db.user.find()
{
"_id" : ObjectId("56340e2d8e142283754e0b84"),
"password" : "$2a$10$9I6OAzexu4SCZo1GmbLO3eUaA6KJhhdd1hJAjbE3OVEM53V2LTQ/m",
"email" : "[email protected]",
"name" : "Raymond"
}
db.role.find()
{
"_id" : ObjectId("56340e2d8e142283754e0b85"),
"name" : "userRole",
"ownerId" : ObjectId("56340e2d8e142283754e0b84"),
"lastupdated" : ISODate("2015-10-31T00:41:17.257Z"),
"created" : ISODate("2015-10-31T00:41:17.257Z"),
"modified" : ISODate("2015-10-31T00:41:17.257Z")
}
db.RoleMapping.find({})
{
"_id" : ObjectId("56340e2d8e142283754e0b86"),
"principalType" : "USER",
"principalId" : "56340e2d8e142283754e0b84",
"roleId" : ObjectId("56340e2d8e142283754e0b85")
}
Need Help.
Many Thanks
The text was updated successfully, but these errors were encountered: