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

inconsistent roles in authorizationChecker depending on where @Authorized decorator is placed #308

Closed
mogusbi opened this issue Oct 16, 2017 · 3 comments
Labels
type: fix Issues describing a broken feature.

Comments

@mogusbi
Copy link

mogusbi commented Oct 16, 2017

Depending on where you place the @Authorized decorator on your controller, the value of the role passed in is returned as either a string or an array which is a bit inconsistent

Take this as an example

@JsonController('/string')
@Authorized('Role')
export class StringController {
  @Get()
  public httpGet () {
    return 'Hello world';
  }
}

@JsonController('/array')
export class ArrayController {
  @Get()
  @Authorized('Role')
  public httpGet () {{
    return 'Hello world';
  }
}

function authorizationChecker (action, role) {
  console.log(role);
}

The StringController will output Role inside the authorizationChecker whilst the ArrayController will return ['Role']. Shouldn't the value of the role remain the same no matter where the decorator is placed?

This is using routing-controllers@0.7.5, express@4.16.2 and node@8.2.1

@NoNameProvided NoNameProvided added the type: fix Issues describing a broken feature. label Oct 16, 2017
@NoNameProvided
Copy link
Member

NoNameProvided commented Oct 16, 2017

You are right, it should be an array all the time.

MichalLytek added a commit to MichalLytek/routing-controllers that referenced this issue Nov 2, 2017
@MichalLytek
Copy link
Contributor

Should be fixed in 0.7.7 (to be released) by 8cc84b0 😉

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: fix Issues describing a broken feature.
Development

No branches or pull requests

3 participants