Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listening to successful login with Spring Security

I want to perform several actions when a User successfully logs in to my app, this actions need some User data as parameters, so is there a way to listen to successful logins with Spring Security 3.0.x? Or any other way to accomplish this?

Thanks!

like image 419
Joaquín L. Robles Avatar asked Jun 16 '11 03:06

Joaquín L. Robles


1 Answers

Use an AuthenticationSuccessHandler

<form-login authentication-success-handler-ref="authenticationSuccessHandler"/>

You can get the username from the Authentication (UsernamePasswordAuthenticationToken) that is passed to onAuthenticationSuccess() and then look up the other user info from there.

like image 111
sourcedelica Avatar answered Nov 13 '22 21:11

sourcedelica