Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Invalidate users
Hello 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
You can give logout url (/c/portal/logout) on button's click event.
try bellow code in localhost:
http://localhost:8080/c/portal/logout
Above code only applicable to logout myself I wants to logout other users as well on single click
Thanks,
I 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).
Hi 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
Maybe 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
Hi 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
Hi ,
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();
Since 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.
Powered by Liferay™