Message Boards
Invalidate users
Invalidate users
Junior Member Posts: 56 Join Date: 5/16/13 Recent PostsHello Everione,
I am looking to invalidate/logout users from my portal developed in Liferay 7.2(CE) using custom portlet on button events..
Is there anybody have idea please suggest for the same.
I tried using AuthenticatedSessionManagerUtil.logout(request, response); but looks not invalidating users from the portal
Thanks
RE: Invalidate users
New Member Posts: 3 Join Date: 3/28/20 Recent PostsYou can give logout url (/c/portal/logout) on button's click event.
try bellow code in localhost:
http://localhost:8080/c/portal/logout
RE: RE: Invalidate users
Junior Member Posts: 56 Join Date: 5/16/13 Recent PostsAbove code only applicable to logout myself I wants to logout other users as well on single click
Thanks,
RE: Invalidate users
Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent PostsI am not sure what you are trying to do? Do you want to logout yourself? Or other people? Or do you want to disable accounts? (Set them inactive).
RE: RE: Invalidate users
Junior Member Posts: 56 Join Date: 5/16/13 Recent PostsHi Christoph, I want to logout other user s whos has loggedin in the portal from other location along with myself.
So Please suggest if it is passible.
Thanks
RE: Invalidate users
Liferay Legend Posts: 6396 Join Date: 9/23/08 Recent PostsMaybe you're not providing the correct request/response parameters?
HttpServletRequest request = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(actionRequest));
HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);
AuthenticatedSessionManagerUtil.logout(request, response);
This should work
RE: RE: Invalidate users
Junior Member Posts: 56 Join Date: 5/16/13 Recent PostsHi Olaf tanks for reply,
Above code is working for current users, I am trying to logout all users who has loggein in the portal from any location.
So please suggest if it is passible
Thanks
RE: Invalidate users
Liferay Master Posts: 591 Join Date: 8/8/14 Recent PostsHi ,
You can logout other users by using their session id , once u have session id you can try below code
HttpSession session = PortalSessionContext.get(sessionId);
session.invalidate();
RE: Invalidate users
Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent PostsSince Liferay uses the application server session, you probably have to look there.
e.g. for Tomcat, it can be done using the Tomcat Web Application Manager.
https://www.baeldung.com/tomcat-manager-app
I am quite sure that this functionality can be implemented inside of an application, but I would also need to research how. Maybe you need to implement your own Manager and handle it from there?
http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html
In case, you use another application server, you need to look there for a way to find and destroy sessions.