RE: Impersonate user option in action button

Vivek Mehta, modified 6 Years ago. Junior Member Posts: 48 Join Date: 4/7/19 Recent Posts
When i am impersonating a user , it works fine for the home page . But then when i click on something or redirects my page to another page then the view is changed to original user perspective. I want to view all the process as impersonate user . Please someone help.
thumbnail
Christoph Rabel, modified 6 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
When you impersonate a user, Liferay adds a "?doAsUserId=<TOKEN>" parameter to the url. When you click somewhere, that parameter is probably lost. In your case, you can:

a) Copy that parameter and add it yourself again, when it is lost (inconvenient, but it might work)
b) I guess, you or some contractor did some customizing. Whoever did that, has to make sure that that parameter is always attached to all urls.

Option a) is probably sufficient, if you just want to check something. Option b) requires some work and probably some changes/fixes on your theme or applications.
Vivek Mehta, modified 6 Years ago. Junior Member Posts: 48 Join Date: 4/7/19 Recent Posts
Thanks christopher for your time. First i also did that using copy paste only and that works fine.But i wanted that thing to happen itself(i.e: doAsuserid should come itself attached to the url).
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Just to add to what Christoph is saying -- if you are creating <portlet:actionURL/>'s in your view, you could also swap those out to use the ext taglib version that Liferay provides, changing the tag to <liferay-portlet:actionURL/>. If you do that, then you can use attributes on the tag to impersonate either the group or the user.​​​​​​​
​​​​​​​
<attribute>
   <name>doAsGroupId</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>doAsUserId</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>