Skip to content

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

@mogusbi

Description

@mogusbi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions