Message Boards

Invalidate users

akaram siddiqui, modified 2 Years ago.

Invalidate users

Junior Member Posts: 56 Join Date: 5/16/13 Recent Posts

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

 

Purvesh Kachhiya, modified 2 Years ago.

RE: Invalidate users

New Member Posts: 3 Join Date: 3/28/20 Recent Posts

You can give logout url (/c/portal/logout) on button's click event.

try bellow code in localhost:

http://localhost:8080/c/portal/logout

akaram siddiqui, modified 2 Years ago.

RE: RE: Invalidate users

Junior Member Posts: 56 Join Date: 5/16/13 Recent Posts

Above code only applicable to logout myself I wants to logout other users as well on single click

 

Thanks,

thumbnail
Christoph Rabel, modified 2 Years ago.

RE: Invalidate users

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts

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

 

akaram siddiqui, modified 2 Years ago.

RE: RE: Invalidate users

Junior Member Posts: 56 Join Date: 5/16/13 Recent Posts

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

thumbnail
Olaf Kock, modified 2 Years ago.

RE: Invalidate users

Liferay Legend Posts: 6396 Join Date: 9/23/08 Recent Posts

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

akaram siddiqui, modified 2 Years ago.

RE: RE: Invalidate users

Junior Member Posts: 56 Join Date: 5/16/13 Recent Posts

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

thumbnail
Mohammed Yasin, modified 2 Years ago.

RE: Invalidate users

Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts

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

 

thumbnail
Christoph Rabel, modified 2 Years ago.

RE: Invalidate users

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts

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.