Search code examples
grailsspring-securitygrails-plugin

Making Grails Spring Security To Authenticate Users With Email


We have a grails app which is working fine with the spring security plugin. As per our requirements, we see that there is no need for username field.

Without username field in the DB we wish to authenticate the users with email and their password. Is that possible to do so?

Thanks in advance.


Solution

  • Simply put in config.groovy

    grails{
        plugins{
                 springsecurity{
                        userLookup.usernamePropertyName = 'myemailfield'
                     }
            }
    }
    

    where myemailfield is the name of your email field in user domain

    or we can do also:

    grails.plugins.springsecurity.userLookup.usernamePropertyName = 'email'