Skip to content

Conversation

@sirNugg3ts
Copy link

There is a bug on the role check, where if a user has multiple roles as string, the check will return false even if the user has the role.

This PR fixes this by spliting the roles by comma (default separator with the admin plugin and organization plugin ), making it into an array and checking if the the user has the role.

Tested using the admin plugin

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 27, 2025

Open in StackBlitz

npm i https://pkg.pr.new/ThallesP/nestjs-better-auth/@thallesp/nestjs-better-auth@64

commit: ea245eb

@ThallesP
Copy link
Owner

There is a bug on the role check, where if a user has multiple roles as string, the check will return false even if the user has the role.

This PR fixes this by spliting the roles by comma (default separator with the admin plugin and organization plugin ), making it into an array and checking if the the user has the role.

Tested using the admin plugin

Kinda weird that the admin plugin separates by a comma instead of an array. Anyway, thanks for the PR. Can you fix the style check?

@sirNugg3ts
Copy link
Author

Kinda weird that the admin plugin separates by a comma instead of an array. Anyway, thanks for the PR. Can you fix the style check?

the schema generated makes the role field a string, and adding through admin.setRole separates them by comma.

Styling, I've run the lint command and nothing changes. the format command is spitting the errors but not fixing them. What is the procedure?

@ThallesP
Copy link
Owner

Kinda weird that the admin plugin separates by a comma instead of an array. Anyway, thanks for the PR. Can you fix the style check?

the schema generated makes the role field a string, and adding through admin.setRole separates them by comma.

Styling, I've run the lint command and nothing changes. the format command is spitting the errors but not fixing them. What is the procedure?

Running bun run format --fix should do the trick

@sirNugg3ts
Copy link
Author

@ThallesP formatted, should run OK now

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.

2 participants