使用Spring Security收听成功登录 [英] Listening to successful login with Spring Security

查看:98
本文介绍了使用Spring Security收听成功登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户成功登录我的应用时执行多项操作,此操作需要一些用户数据作为参数,因此有没有办法使用Spring Security 3.0.x监听成功登录?或任何其他方式来实现这一目标?

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?

谢谢!

推荐答案

使用 AuthenticationSuccessHandler

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

您可以从身份验证(UsernamePasswordAuthenticationToken)获取传递给onAuthenticationSuccess()的用户名,然后查看从那里获取其他用户信息。

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

这篇关于使用Spring Security收听成功登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆