strongloop-community / loopback-acl-route Goto Github PK
View Code? Open in Web Editor NEWLoopBack route based ACL
License: Other
LoopBack route based ACL
License: Other
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
User.create({name: 'Raymond', email: '[email protected]', password: 'foobar'}, function(err, user) {
console.log('Created user ', user)
console.log('')
Role.create({"name": "userRole", "ownerId": ObjectID(user.id)}, function(err, role) {
console.log('Created role ', role)
console.log(err)
console.log('')
role.principals.create({principalType: RoleMapping.USER, principalId: user.id}, function(err, p) {
if (err) {
console.log(err)
throw err
}
console.log('Created principals')
console.log(p)
console.log('')
Role.isInRole('userRole', {principalType: RoleMapping.USER, principalId: user.id}, function(err, isInRole) {
console.log('Role.isInRole userRole')
console.log(isInRole)
console.log('')
})
})
})
})
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
loopback-acl-route package does not exist in npm
Hello, I would like to use this middleware but the thing is I create roles in a boot script, so I can't get them to configure the middleware. Do you have a suggestion?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.