完成后,创建自定义AuthenticationSuccessHandler并调用默认的AuthenticationSuccessHandler

时间:2017-08-30 14:58:17

标签: spring spring-mvc grails groovy

我想创建CustomAuthenticationSuccessHandler以向每个用户登录添加日志:

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。

1 个答案:

答案 0 :(得分:1)

You're doing it wrong essentially.

Instead of overriding the success handler, you should register an event listener.

Config: .buttonClass{ vertical-align:middle; }

Register a class as a bean

StratifiedKFold(n_splits=10, shuffle=True, random_state=0)