留言板

Impersonate User and Friendly URL

Paul Proulx,修改在9 年前。

Impersonate User and Friendly URL

New Member 发布: 1 加入日期: 14-10-27 最近的帖子
We are using liferay 6.1.

I have run into a problem when impersonating a user that I can't seem to get around. This happens whether I create my own impersonation link or impersonate through the Liferay Control Panel.

The friendly url is created in the control panel and the link defined in a theme .vm file. <a href="/my-account">My account</a>

Once I impersonate a user, if I click on a link that is a friendly url the doAsUserId parameter is lost. Because I have an interceptor that checks this parameter by doing currentLiferayUser = PortalUtil.getUser(request), it comes up with the user that originally logged in since doAsUserId is gone.

My question is, how do I maintain the doAsUserId parameter? I have tried to define routes in a routes.xml file which is setup in the liferay-portlet.xml file but so far no luck. Do I have my routes.xml set up incorrectly? It seems as if doAsUserId should persist with a friendly URL so maybe this is a bug?

Thanks, Paul

liferay-portlet.xml:

<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>my-account</friendly-url-mapping>
<friendly-url-routes>com/newscom/friendlyurl/my-account-friendly-url-routes.xml</friendly-url-routes>


my-account-friendly-url-routes.xml:

<routes>
<route>
<pattern>/my-account/{doAsUserId:\d+}</pattern>
<generated-parameter name="doAsUserId">{doAsUserId}</generated-parameter>
</route>
</routes>
thumbnail
Zsolt - Jácint Balogh,修改在8 年前。

RE: Impersonate User and Friendly URL

Junior Member 帖子: 91 加入日期: 13-10-9 最近的帖子
Hi All,

I have the same problem with liferay 6.2 GA2.
How can I map the doAsUserId parameter?
This pattern "<pattern>.../{doAsUserId:\d+}</pattern>" will not work because this is passed like "?doAsUserId=sGl59sHgCjzHid6%2FvH%2FeEQ%3D%3D."

I have a custom url mapper class but I can't see this in the populateParams method parameterMap variable.

Regards,
Zsolt