By default spring security gives you three domain classes User, Role, and UserRole. I can easily make accounts in my bootstrap.groovy file in grails 2.4.4 doing this
User admin = new User(username:'admin', password:'secret', enable:true, accountExpired:false, accountLocked:false, passwordExpired:false).save();
Role a = new Role(authority:'ROLE_ADMIN').save()
UserRole.create(admin, a);
but how in the world do you create one when in the session? I have made classes that extend User, Role, and UserRole. I am able to save a new Role and a User, but I'm not able to save the relationship between them. I realize this must have something to do with UserRole.create instead of save that User and Role use, I can't find any documentation on it because everyone just uses boot strap.
Aucun commentaire:
Enregistrer un commentaire