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: How to get a parameter or key in Post Logout Event ?
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:
P.V.B.Raju.@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(); Note: Here we are getting Command with null value.Thaks & Regards, System.out.println("command: "+httpServletRequest.getParameter("command")); // Here we are getting Command with null value }
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.
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.
Additionally, there is no guarantee that anything will be included in the request, from parameters to headers to attributes, ...
David H Nebinger:
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.
Additionally, there is no guarantee that anything will be included in the request, from parameters to headers to attributes, ...