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

User update removes all user roles #89

Closed
alexbulyha opened this issue Feb 12, 2018 · 2 comments
Closed

User update removes all user roles #89

alexbulyha opened this issue Feb 12, 2018 · 2 comments
Assignees

Comments

@alexbulyha
Copy link

alexbulyha commented Feb 12, 2018

When updating a user, it removes all role associations, unless the user has none, than it does work.

Meaning you always have to update the user twice (re-selecting all roles).
I noticed that behaviour for versions:
3.1.0
3.1.1

I believe this is due to grails 3.3 taking hibernate a little different.
Currently this plugin simply deletes all UserRole and recreates the new ones.
However, as the whole function is inside a @transactional statement, this does not work as planned.
Even when setting flush to true, it only creates the diff of roles.
This means, even though having deleted (and flushed), the old userRoles are still recognized on "create" and are not beeing re-created.

I have played around a little bit and found only one working solution:
Do not delete all, check what to delete and what to create

I don't know if this is the "clean" way to do it, however I will make a PR with this change, and you can decide.

If it's not ok, please implement a different fix, because as of now, this is a major problem for us.
You want to change the user password -> roles get deleted.

EDIT:
I have also noticed, that with the current master, it is not possible to update users at all.

Setup:
Groovy 2.4.11
Java 1.8.0_161
grails 3.3.0
gradle 3.5
gorm 6.1.6.RELEASE

BR,
Alex

@alexbulyha
Copy link
Author

alexbulyha commented Feb 12, 2018

This PR should fix the ROLE problem, not the general saving problem however (mentioned in "EDIT").
I tested the same code changes with 3.1.1 tag and am going to use that in my grails application for now.

For 3.1.2 (the not released version, master as of 12.02):
USERNAME may not have been updated. Either the form was submitted twice or possible CSRF attempt. Be careful what you click.

@ddelponte ddelponte self-assigned this May 1, 2018
@ddelponte
Copy link
Collaborator

I have used @AlexBoulyga 's PR for inspiration and created a new at #95 which has been assigned to @sdelamo for review.

ddelponte added a commit that referenced this issue Jul 19, 2018
- Added `webdrivermanager` dependency which will automatically download the chrome driver if it doesn't exist on the test machine
- Modified simple integration `UserSpec` test to verify the fix for Issue #89
@ilopmar ilopmar closed this as completed Sep 20, 2018
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

3 participants