0
votes

I am trying to get more details when I log into my Grails application using Spring Security.

For e.g.:

When I log in using :

http://localhost:8080/XXX/auth/login 

I get authentication success and below is the sample response.

{"username":"lalit","roles":["XXX"],"access_token":"something"}

Instead of this, I would also like to return some more user related data like full name.

{"username":"lalit","roles":["XXX"],"access_token":"something","fname":"Lalit Agarwal"}

So, you could see full name also returned as response when I log in.

Note: I have already added a custom field fullName using this : http://grails-plugins.github.io/grails-spring-security-core/guide/userDetailsService.html

1

1 Answers

0
votes

The link you noted pretty much outlines exactly what you need to do. You should extend the GormUserDetailsService (or write your own and make sure it implements GrailsUserDetailsService) to make sure that when loadUserByUsername is called, it add the full name to the returned object. Then you just need to add the new bean to your resources.groovy file under the name userDetailsService.