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

UserManager.AddToRolesAsync() and RemoveFromRolesAsync() fail on any conflict #64

Open
CollectorOfBolts opened this issue May 16, 2024 · 0 comments

Comments

@CollectorOfBolts
Copy link

When adding multiple roles or generally updating a user's roles, I'd like to be able to just give UserManager.AddToRolesAsync() the full list of roles that the user should have and have it add any new roles. As it currently is, if the user already has even 1 of the roles being assigned, the operation reports as a failure, at best having added any new roles in the list prior to the role that the user already has.

Similarly, when removing roles, UserManager.RemoveFromRolesAsync() will fail if the user does not have any of the given roles when, in my opinion, it should ignore those and continue with removing any that the user does have.

Looking at the code, it appears that it could be as simple as changing return new IdentityResult(Resources.UserAlreadyInRole); to continue; in UserManager.AddToRolesAsync() and changing return new IdentityResult(Resources.UserNotInRole); to continue; in UserManager.RemoveFromRolesAsync().

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

No branches or pull requests

1 participant