Grails Spring Security use email to login

Posted By : Akash Sharma | 08-Feb-2014

Grails Spring Security

Spring security uses two fields combination for authenticating a user while login.

First is :

grails.plugin.springsecurity.userLookup.usernamePropertyName

and the second is password field.

By default field usernamePropertyName is set to username in DefaultSecurityConfig.groovy file of spring security core plugin.

 

You can override this feature and use any other field of User domain like email or mobileNumber for user authentication.

If you want to authenticate a user via email and password combination while login, you can add this line to your conf.groovy file

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

 

Now after adding this line , spring security will store user’s email in session.

So , the output of tag <sec:username/> will give you current user’s email.

 

Thanks

 

About Author

Author Image
Akash Sharma

Akash is a bright Groovy and Grails developer and have worked on development of various SaaS applications using Grails technologies. Akash loves playing Cricket and Tennis

Request for Proposal

Name is required

Comment is required

Sending message..