RE: How to add an impersonation listener in Liferay DXP ?

Vishnu S Kumar, modified 6 Years ago. Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts
We have some logic to perform  when an authorized user ends impersonating a site user.  From my understanding, the 'be yourself again' link in the product menu to end impersonation should be the place to override. The JSP file is found inside the "liferay-portal/modules/apps/web-experience/product-navigation/product-navigation-user/src/main/resources/META-INF/resources/user_body.jsp" .  Is this the right approach to solve this issue? 

​​​​​​​Thanks!
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
You can't rely on a user clicking "be yourself again".  After all, when you impersonate you typically get a separate tab or window as the user, so often times I just close that tab and go back to my original.

It is just like you cannot depend upon users logging out. They may expire due to being idle, they might have just driven into a tunnel losing network connectivity, ...

And "be yourself again" I don't believe it triggers any sort of event like starting impersonation does...
Vishnu S Kumar, modified 6 Years ago. Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts
Thanks David. I have to figure out some other ways to do that
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Like I said, you can't rely on that link, there are zero guarantees that anyone would use it...
Vishnu S Kumar, modified 6 Years ago. Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts
ok, I got it. 
Vishnu S Kumar, modified 6 Years ago. Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts
Hi David, After  peer discussion about your answer,  it came up that we don't need to address the scenarios of  ending impersonation other than clicking the 'be yourself again' link. So, we need to override the  'user_body.jsp' to add our custom logic. However, examples shown in the liferay documentations are showing JSP overriding inside '/portal-web/docroot/html' folder. Can we use the same way to override this 'user_body.jsp'  inside "liferay-portal/modules/apps/web-experience/product-navigation/product-navigation-user/src/main/resources/META-INF/resources".
David H Nebinger:

Like I said, you can't rely on that link, there are zero guarantees that anyone would use it...
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
No, for that one you need a fragment bundle to override the JSP.
Vishnu S Kumar, modified 6 Years ago. Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts
Thank you so much. It worked!
David H Nebinger:

No, for that one you need a fragment bundle to override the JSP.