loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Add role.principals() and role.roles() to API docs

Open mike-aungsan opened this issue 11 years ago • 8 comments

@crandmck

Cannot find API info of these two functions from the following code.

Line 50:

userRole.principals(function(err, principals) {
        assert.equal(principals.length, 1);
});
userRole.roles(function(err, roles) {
        assert.equal(roles.length, 1);
});

https://github.com/strongloop/loopback/blob/9a33602458712afecedd25062f02bd8b5c4e01a5/test/role.test.js

mike-aungsan avatar Nov 02 '15 20:11 mike-aungsan

I don't know anything about these methods. I don't see them in the source code. I do see principals in the role.json file, so that might be the source of userRole.principals.

Someone in engineering (eg. @ritch) needs to take this and let me know if I need to add something to docs, and if so, what. I suspect it's not something that we should document, but I don't know for sure.

crandmck avatar Nov 03 '15 00:11 crandmck

Those functions come from relations

ritch avatar Nov 03 '15 02:11 ritch

@ritch I realize they come from relations, but if those relations are intrinsic to how roles work, then should we add those functions to the API docs?

crandmck avatar Nov 03 '15 18:11 crandmck

Yes we should add them, similarly to how we've added the PersistedModel methods.

ritch avatar Nov 03 '15 20:11 ritch

So it's been more than a year already. Any updates on where this is at?

lobabob avatar Jan 10 '17 00:01 lobabob

I'll try to sort it out.

crandmck avatar Jan 12 '17 23:01 crandmck

Any update on this? Looking for a way to programmatically remove users from the admin role. The docs only explain giving a user the admin role via Role.principals.create() but not taking it away again. Is there a principals.destroy() or principals.delete() or something like that to do that?

buokae avatar Oct 25 '18 16:10 buokae

Nevermind, I'll persist RoleMapping to my datasource and work with that. I'll see if I can update the docs a little bit.

buokae avatar Oct 26 '18 08:10 buokae