Spring-Security: Call method after authentication

后端 未结 7 1496
一整个雨季
一整个雨季 2021-02-01 04:52

I\'d like to track when users are logging in to my application. I have some code that I would like to execute right after the user is authenticated. The problem is, I can\'t fig

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-01 05:19

    If you want to avoid reading all the thread : curated version with annotations & a bit more explanatory :

    import org.springframework.context.ApplicationListener; 
    import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
    import org.springframework.security.core.userdetails.User;
    import org.springframework.stereotype.Component;
    
    @Component 
    public class LoginSuccessListener implements ApplicationListener

提交回复
热议问题