Reputation: 3776
I'm using the Spring Security plugin, in combination with the Spring Security UI plugin.
They both work like a charm, but my problem is that I don't want my user to have a username, instead he/she should use the e-mail as username.
So in the register-phase I tried removing the username from the registration-page and setting
newUser.username = params.email
So that the plugins still can access the variable username, but this gave me validation errors and I just can't figure out a way to solve it.
Any ideas? Has anyone done anything similar?
Upvotes: 2
Views: 1314
Reputation: 766
I have recently done this by copying views and controllers from spring security plugin to my grails-app and updated view to display emailAddress as oppose to username. I also replaced username property with emailAddress in User domain class. Make sure you update the constrains as follows:
static constraints = {
emailAddress email: true, blank: false, unique: true
password blank: false, password: true
}
What dimcookies suggest is correct and works for old version of Grails, the new syntax configuration, at least for Grails 2.3.1, is:
grails.plugin.springsecurity.userLookup.usernamePropertyName = 'emailAddress'
Upvotes: 0
Reputation: 1930
You can modify the default User field that spring security uses
In your Config.groovy add the following
grails.plugins.springsecurity.userLookup.usernamePropertyName = 'XXX'
where XXX is the field of the User entity to be used
You can check the configuration attributes here
Upvotes: 4