I just added the spring security plugin to my grails application. I have a question about adding users and their associated roles. I am able to do it correctly in the bootstrap but was wondering how to do it in the GSP page. I have a gsp page with the corresponding fields. when submited, it call the save method. my user domain controller extends SecUser. below is the example:
class User extends SecUser {
String fname
String lname
Date dateCreated
Date lastUpdated
static constraints = {
fname (blank:false)
lname (blank:false)
}
String toString(){
fname & " " & lname
}
}
When the user is saved, it saves only items in the user domain, not the SecUser. Does anyone have an example GSP and controller code to save the all the user data?
I perceive that you have two problems :
For the first question:
To create GSPs and everything you need to have a CRUD on your User class, I suggest that you use scaffolding. If will take care of all of this for you.
Remove everything from your UserController or create another controller with only the following code:
then, navigate to your UserController ({your_app}/user/index) and everything should be there.
If you want to have an actual controller and gsps and modify how they work, use the grails command :
grails generate-all your.package.UserFor the second question :
Unless there is a problem with your SecUser class (transient fields for example), all fields inherited from SecUser should be saved through a User.save()
Let me know how it goes,
Vincent Giguère