开发者

Overriding AjaxAwareAuthenticationSuccessHandler.onAuthenticationSuccess Gotchas

I wrote a custom success handler for our application because the client was to redirect to specific pages based on roles. In doing this, I was originally calling super.onAuthe开发者_JS百科nticationSuccess but since it already does redirects, when I attempted to redirect again, obviously, there were state exceptions.

So what I'm doing now is checking roles and redirecting accordingly and falling back on super.onAuthenticationSuccess...

@Override
public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response,
                                      final Authentication authentication) throws ServletException, IOException {

    if (goToSomePage) {
      response.sendRedirect(request.contextPath + '/admin/index')
    }else{
      super.onAuthenticationSuccess(request, response, authentication)
    }
}

I'm wondering if I'm going to run into issues later because something in the parent onAuthenticationSuccess method is required that I'm not doing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜