RE: How to get a parameter or key in Post Logout Event ?

thumbnail
Bangaru Raju Potnuru, modified 6 Years ago. New Member Posts: 22 Join Date: 11/22/14 Recent Posts
Hi Team,We have a requirement to build a functionality in Liferay-7 that ,when a User clicks on Logout ,we need to perform certain action and redirected to particular page based on the User activity.Our Approach:

@Component(immediate = true, property = { "key=logout.events.post" }, service = LifecycleAction.class)
public class PostLogOutActionPortlet implements LifecycleAction {
    public static final Log LOGGER = LogFactoryUtil.getLog(PostLogOutActionPortlet.class);
    @Override
    public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
        LOGGER.info("PostLog Out called");
        HttpServletRequest httpServletRequest = lifecycleEvent.getRequest();
        HttpServletResponse httpServletResponse = lifecycleEvent.getResponse();
        
        System.out.println("command: "+httpServletRequest.getParameter("command"));
   // Here we are getting Command with null value
}
Note:    Here we are getting Command with null value.Thaks & Regards,
P.V.B.Raju.
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Bangaru,

Hmmm ... I'm not sure a pre or a post logout hook is the best way to try to do this. Those hooks are also called when the session timeout occurs. I think what you would have to do is override the Portal Struts action for the path /c/portal/logout -- and then in that class do whatever you need to do, ultimately routing to the original action to make sure all the things that Liferay needs to do to perform the logout work. Here is a link to a sample project: https://github.com/liferay/liferay-blade-samples/blob/master/gradle/extensions/struts-action/src/main/java/com/liferay/blade/samples/strutsaction/BladeStrutsAction.java

.. except in your case, you want to use a path=/portal/logout. I would imagine that you would also need to use a JSP fragment or something to override the default "sign out" link to use a render parameter that passes your "command" value. 
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Additionally, there is no guarantee that anything will be included in the request, from parameters to headers to attributes, ...
thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
David H Nebinger:

Additionally, there is no guarantee that anything will be included in the request, from parameters to headers to attributes, ...
In fact, as it's post logout (as opposed to pre or during), I'd be shocked if there was any leftover private data available and would consider it as a security issue.