In my Config.groovy I used:
grails.plugins.springsecurity.useSecurityEventListener = true
grails.plugins.springsecurity.onInteractiveAuthenticationSuccessEvent = { e, appCtx ->
User.withTransaction {
def user = User.findById(appCtx.springSecurityService.principal.id)
if(!user.isAttached())
user.attach()
user.lastLoginDate = new Date()
user.save(flush: true, failOnError: true)
}
}
My User domain has this field and I don't get any errors while logging in, however, the field is not updated.
I tried debugging everything from org.hibernate but I couldn't find any updateor other relevant statements.
Is there anything else I need to add anywhere in order to get this working?
For the record:
- Grails 1.3.7
- Spring Security Core 1.1.2
- Hibernate 1.3.7