Skip to content

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

Merged
bajtos merged 1 commit into
strongloop:masterfrom
ebarault:getRoles-to-return-only-role-names
Nov 30, 2016
Merged

Role.getRoles() to return only role names#2975
bajtos merged 1 commit into
strongloop:masterfrom
ebarault:getRoles-to-return-only-role-names

Conversation

@ebarault

@ebarault ebarault commented Nov 23, 2016

Copy link
Copy Markdown
Contributor

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

slnode commented Nov 23, 2016

Copy link
Copy Markdown

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

@slnode

slnode commented Nov 23, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch?

3 similar comments
@slnode

slnode commented Nov 23, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch?

@slnode

slnode commented Nov 23, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch?

@slnode

slnode commented Nov 23, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch?

@bajtos

bajtos commented Nov 23, 2016

Copy link
Copy Markdown
Member

@slnode ok to test

@bajtos

bajtos commented Nov 23, 2016

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
Contributor

related #2420

@bajtos bajtos left a comment

Copy link
Copy Markdown
Member

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?

Comment thread test/role.test.js
});
},
function(next) {
Role.getRoles(

Copy link
Copy Markdown
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

bajtos commented Nov 30, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

thanks for finalizing @bajtos

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

bajtos commented Nov 30, 2016

Copy link
Copy Markdown
Member

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