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

Role.getRoles() to return only role names #2975

Merged

Conversation

ebarault
Copy link
Contributor

@ebarault ebarault commented Nov 23, 2016

Description

Currently the return type of Role.getRoles() method is inconsistent: role names are returned for smart roles and role ids are returned for static roles (configured through user-role mapping)

This PR proposes to return only role names in Role.getRoles()
Tests have been updated.

Related issues

  • None

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

@bajtos, @superkhau could you please have a look?

@slnode
Copy link

slnode commented Nov 23, 2016

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@slnode
Copy link

slnode commented Nov 23, 2016

Can one of the admins verify this patch?

3 similar comments
@slnode
Copy link

slnode commented Nov 23, 2016

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Nov 23, 2016

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Nov 23, 2016

Can one of the admins verify this patch?

@bajtos
Copy link
Member

bajtos commented Nov 23, 2016

@slnode ok to test

@bajtos
Copy link
Member

bajtos commented Nov 23, 2016

@ebarault thank you for the pull request. Your proposal makes sense to me, however I am concerned about backwards compatibility. Can we implement your enhancement behind a flag, so that users can decide whether to use current behaviour (by default) or get role names only (when the flag is set)?

One options is to add a new optional parameter options to Role.getRoles method:

Roles.getRoles(ctx, cb); // works as before
Roles.getRoles(ctx, { returnRoleNames: true }, cb); // the new way

@bajtos bajtos self-assigned this Nov 23, 2016
@ebarault
Copy link
Contributor Author

@bajtos : makes sense. Renamed the option 'returnOnlyRoleNames'. Rollbacked original test, and added a new one with the option. please have a look

@davidcheung
Copy link
Contributor

related #2420

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small nitpick, the rest looks good to me.

After you address my comment, could you please squash all commits into a single one and provide a descriptive error message following our 50/72 convention?

@@ -254,6 +254,20 @@ describe('role model', function() {
},
function(next) {
Role.getRoles(
{principalType: RoleMapping.USER, principalId: user.id},
{'returnOnlyRoleNames': true},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the quotes are not needed, can you remove please?

@bajtos
Copy link
Member

bajtos commented Nov 30, 2016

Actually, let me make those changes for you, to get the patch landed sooner.

Currently the return type of Role.getRoles() method is inconsistent:
role names are returned for smart roles and role ids are returned for
static roles (configured through user-role mapping).

This commit adds a new option to Role.getRoles() allowing the caller
to request role names to be returned for all types of roles.
@bajtos bajtos force-pushed the getRoles-to-return-only-role-names branch from 6a26cee to b0d6c4a Compare November 30, 2016 15:47
@ebarault
Copy link
Contributor Author

thanks for finalizing @bajtos

@bajtos bajtos merged commit ca3ec13 into strongloop:master Nov 30, 2016
@bajtos
Copy link
Member

bajtos commented Nov 30, 2016

Landed, thank you for the contribution!

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

Successfully merging this pull request may close these issues.

5 participants