Liferay - autologin hook/portlet doesn't logout the current user

雨燕双飞 提交于 2019-12-13 05:31:29

问题


It seems Liferay's autologin hook doesn't logout the current user. So I tried to do it programmatically with the following method call:

request.getSession().invalidate();

but with no success.Does anyone had the same issues with the auto-login hook ?


回答1:


Hi to logout you have to invalidate the cookies and then invalidate the session see the Liferay LogoutAction for more detail

https://github.com/liferay/liferay-portal/blob/6.2.x/portal-impl/src/com/liferay/portal/action/LogoutAction.java




回答2:


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.

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

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);


来源:https://stackoverflow.com/questions/36174285/liferay-autologin-hook-portlet-doesnt-logout-the-current-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!