I use spring security core plugin. I want to put an object in session just after user has logged in. What I've discovered so far is that there is grails.plugin.springsecurity.LoginController in the plugin. And it has method which is called ajaxSuccess which seems to be invoked just after successfull authentication. So I decided to create another LoginController which extends default one and overrides this method:
@Secured('permitAll')
class LoginController extends grails.plugin.springsecurity.LoginController {
def ajaxSuccess() {
session['somevproperty'] = someValue
super.ajaxSuccess()
}
}
but debugging shows that this method is never invoked. What is going wrong? May there is another way to do what I want? Thank you!
Spring security has it own event listeners. I prefer you use that.
http://grails-plugins.github.io/grails-spring-security-core/guide/events.html
Sample code from above link for success login.
package com.foo.bar
import org.springframework.context.ApplicationListener
import org.springframework.security.authentication.event. AuthenticationSuccessEvent
class MySecurityEventListener implements ApplicationListener<AuthenticationSuccessEvent> {
void onApplicationEvent(AuthenticationSuccessEvent event) {
// handle the event
}
}
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