Not able to invoke post logout event in liferay dxpNot able to invoke post logout event in liferay dxphttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1086464702024-03-28T19:18:30Z2024-03-28T19:18:30ZRE: Not able to invoke post logout event in liferay dxpAlfonso Criscihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1118146472018-12-14T13:56:52Z2018-12-14T13:56:52Z<blockquote>
<div class="quote-title">Sadanand Ghadage:</div>
<div class="quote">
<div class="quote-content">Hi Experts, I have CAS integrated with my
liferay dxp portal. In my portal my requirement is, I have to
redirect user to specific page on role basis after logout. For
this I have tried with "logout.post.event" and
overriding "\portal\logout" struts action but no luck.
In both the cases event/action is not getting triggered. user is
directly redirecting to the url which we have mentioned in the
"logout url" of the CAS configuration. How could I need
to handle this ? Thanks in advance ! Regards, Sadanand</div></div></blockquote>
<p>Hi Sadanand,</p>
<p> </p>
<p>Within our internal project we found an approach for this, I am
sharing it hereby so it may help you and other users:</p>
<p> </p>
<pre>
package PostLogoutAction.portlet;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.events.LifecycleAction;
import com.liferay.portal.kernel.events.LifecycleEvent;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
import com.liferay.portal.kernel.util.SessionClicks;
import org.osgi.service.component.annotations.Component;
/**
* @author test
*/
@Component(
immediate = true,
property = {"key=logout.events.post"},
service = LifecycleAction.class
)
public class SidebarModiferPortlet implements LifecycleAction {
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
SessionClicks.put(
lifecycleEvent.getRequest(),
"com.liferay.product.navigation.product.menu.web_productMenuState",
"closed");
}
}</pre>Alfonso Crisci2018-12-14T13:56:52ZRE: Not able to invoke post logout event in liferay dxpDavid H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1086430222018-05-22T06:05:42Z2018-05-22T06:05:42ZWhen you redirect to the CAS logout, it is supposed to be the end of your session, so the logout.post.event likely would never get invoked because the session, itself, is completely gone by then.<br /><br />You might be able to figure out something using a logout.pre.event, but even that would be challenging.<br /><br />If I absolutely had to solve this, I would probably want to customize the CAS module. I would still be using the logout URL for CAS (you do need to let CAS handle the logout), but I would want to derive the redirect URL based on user role and pass that along to CAS.<br /><br />I know you can have CAS redirect after the logout is done, but this suggestion is dependent upon being able to send the desired redirect and have CAS honor the provided parameter as the redirect location.David H Nebinger2018-05-22T06:05:42ZNot able to invoke post logout event in liferay dxpSadanand Ghadagehttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1086464692018-05-22T05:52:28Z2018-05-22T05:52:28ZHi Experts,<br /><br />I have CAS integrated with my liferay dxp portal. <br />In my portal my requirement is, I have to redirect user to specific page on role basis after logout. For this I have tried with "logout.post.event" and overriding "\portal\logout" struts action but no luck. In both the cases event/action is not getting triggered. user is directly redirecting to the url which we have mentioned in the "logout url" of the CAS configuration.&