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 merge (ALL) does not work #144

Closed
BitDesert opened this issue Dec 12, 2022 · 2 comments
Closed

Role merge (ALL) does not work #144

BitDesert opened this issue Dec 12, 2022 · 2 comments
Assignees
Labels
Status: Confirmed Confirmed issue Type: Bug Something isn't working
Milestone

Comments

@BitDesert
Copy link

The role merger implemented in f540e44 and referenced in #127 does not work.

With the configuration option roleMerge: RoleMerge.ALL and a class decorator @Roles({ roles: ['role1'] }) and a handler decorator @Roles({ roles: ['role2'] }) handler I get the following error at nest-keycloak-connect/guards/role.guard.js:79:36:

ERROR [ExceptionsHandler] Found non-callable @@iterator
TypeError: Found non-callable @@iterator

const mergedRoleMetaData = this.reflector.getAllAndMerge<
RoleDecoratorOptionsInterface[]
>(META_ROLES, [context.getClass(), context.getHandler()]);
if (mergedRoleMetaData) {
rolesMetaDatas.push(...mergedRoleMetaData);
}

This is probably due to Nest not being able to merge the array in the roles property. Related Nest function:
https://github.com/nestjs/nest/blob/a80df520bc0f5847eece8d1fd0d5a6f10b3ab6a6/packages/core/services/reflector.service.ts#L52-L76

Did I implement it wrong or is a custom merge method needed?

@ferrerojosh ferrerojosh self-assigned this Dec 16, 2022
@ferrerojosh
Copy link
Owner

The nest function seem to be checking if it is an array. Does it have to do with the fact that we're passing an object instead ? It checks if a and b are objects and are merging them via object spread.

@ferrerojosh ferrerojosh added the Type: Bug Something isn't working label Dec 16, 2022
@sbabych
Copy link

sbabych commented Feb 6, 2024

same is here:

[Nest] 7605  - 02/06/2024, 1:05:30 PM   ERROR [ExceptionsHandler] Spread syntax requires ...iterable[Symbol.iterator] to be a function
TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a function
  at RoleGuard.<anonymous> 

@ferrerojosh ferrerojosh added the Status: Confirmed Confirmed issue label Mar 17, 2024
@ferrerojosh ferrerojosh added this to the 2.0 milestone Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Confirmed Confirmed issue Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants