My Grails app uses the Spring Security plugin. Whenever a user successfully logs in I want to:
I need to handle logout events similarly, which was pretty straightforward because the plugin provides a bean named logoutSuccessHandler
that can be overriden. I was hoping to similarly find a bean named loginSuccessHandler
, but no such luck.
I read the page in the plugin's docs about event handling, but neither of the event handling mechanisms appears to give me access to the current request or session.
If you want to do some stuff upon successful login. You can listen to InteractiveAuthenticationSuccessEvent
class AuthenticationSuccessEventListener implements
ApplicationListener<InteractiveAuthenticationSuccessEvent> {
@Override
public void onApplicationEvent(InteractiveAuthenticationSuccessEvent event) {
.......do some stuff here
}
}
And then register AuthenticationSuccessEventListener as a spring bean in resources.groovy You can do whatever you want here, however you wont be able to do redirect from listener.
Here's another similar question
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