0
當我想創建CustomAuthenticationSuccessHandler
添加日誌,每個用戶登錄調用默認AuthenticationSuccessHandler:創建自定義AuthenticationSuccessHandler,做
class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler{
UserService getUserService() {
return ApplicationContextHolder.getBean('userService')
}
@Override
public void onAuthenticationSuccess(HttpServletRequest req,
HttpServletResponse res, Authentication auth) throws IOException,
ServletException {
userService.postLoginMessage(auth.principal.username, null)
}
}
這是很簡單的代碼,並且效果很好,但現在我有沒有返回值。有沒有辦法在自定義代碼運行後返回默認值AuthenticationSuccessHandler
或返回默認值?
我的意思是返回Authentication
json。