且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Liferay-自动登录挂钩/Portlet不会注销当前用户

更新时间:2023-12-01 23:50:16

主要问题是,如果用户登录,则不会执行自动登录过滤器,因此您无法在其中执行任何注销操作.

The main problem is that if a user is logged in, an autologin filter is not executed, so you can't do any logout action in it.

对于我的解决方案,我创建了一个servlet过滤器,该过滤器检查一些参数以进行自动登录并执行注销过程.要创建过滤器,请遵循以下指南: http://www. liferaysavvy.com/2016/02/liferay-servlet-filter-hooks.html

For my solution I created a servlet filter which check some paramteres for autologin and execute logout process. For creating a filter I follow this guide: http://www.liferaysavvy.com/2016/02/liferay-servlet-filter-hooks.html

我的 doFilter 方法中的注销代码(在servlet过滤器中):

My code for logout in doFilter method (in servlet filter):

final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
final HttpSession session = request.getSession(false);

if (session != null)
{
    session.invalidate();
}

filterChain.doFilter(request, response);