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?
Load the user instance using the cached id in the GrailsUser instance:
def user = User.get(SpringSecurityService.principal.id)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With