views:

36

answers:

1

I'm using spring security, and I need to get the User domain object in a controller.

If I call SpringSecurityService.getPrincipal(), I get back an object of type org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser. However, what I'm looking for is the User domain object I've defined in my Config.groovy like so:

grails.plugins.springsecurity.userLookup.userDomainClassName = 'project.auth.User'

How can I best get at the User domain object?

+4  A: 

Load the user instance using the cached id in the GrailsUser instance:

def user = User.get(SpringSecurityService.principal.id)
Burt Beckwith