You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example that reproduces the problem uploaded to Github
Full description of the issue provided (see below)
Steps to Reproduce
Create a new Grails 4.X application
add compile 'org.grails.plugins:spring-security-core:4.0.3' to build.gradle
run grailsw s2-quickstart myapp User Role
create at least one role and two users, e.g. in Bootstrap.groovy: Role role = new Role(authority: 'ADMIN').save(); User user1 = new User(username: 'user1', password: 'abc123').save(); User user2 = new User(username: 'user2', password: 'abc123').save();
Attach users to roles: UserRole.create(user1, role, true); UserRole.create(user2, role, true)
Call UserRole.removeAll(user1) from anywhere, e.g. TestController.groovy: User user = User.findByUsername('user1'); UserRole.removeAll(user); user.delete()
Expected Behaviour
To my understanding UserRole.removeAll(User u) {...} should remove every UserRole entry connected to the user u.
Actual Behaviour
Instead of just one entry being deleted, the method deletes all UserRole entries in the database.
This appears to be similar to the problem mentioned in this S2UI issue, which includes an example.
I ran into that same problem, and in the course of investigating it, discovered a workaround: Copy the plugin method to a new class extending the plugin's class -- for some reason, with no code changes, just that override makes it work as expected, deleting only the intended UserRole(s).
In case that workaround helps anyone else (including perhaps shedding some light on the cause of the problem), full details are in this comment on that S2UI issue.
Task List
Steps to Reproduce
compile 'org.grails.plugins:spring-security-core:4.0.3'
tobuild.gradle
grailsw s2-quickstart myapp User Role
Bootstrap.groovy
:Role role = new Role(authority: 'ADMIN').save(); User user1 = new User(username: 'user1', password: 'abc123').save(); User user2 = new User(username: 'user2', password: 'abc123').save();
UserRole.create(user1, role, true); UserRole.create(user2, role, true)
UserRole.removeAll(user1)
from anywhere, e.g.TestController.groovy
:User user = User.findByUsername('user1'); UserRole.removeAll(user); user.delete()
Expected Behaviour
To my understanding
UserRole.removeAll(User u) {...}
should remove every UserRole entry connected to the useru
.Actual Behaviour
Instead of just one entry being deleted, the method deletes all UserRole entries in the database.
This caught my attention in the GORM for Hibernate docs:
Environment Information
Example Application
The text was updated successfully, but these errors were encountered: