Fórum

Hook on LayoutAction

Mitko Zafirovski, modificado 11 Anos atrás.

Hook on LayoutAction

Junior Member Postagens: 26 Data de Entrada: 01/03/12 Postagens Recentes

For couple of days now i was trying to get the redirect on liferay wroking. Usually when u access a page that requires the user to log in it redirect you to the login page by passing its own querry parameter "http://localhost:8080/web/guest/login?_58_redirect=%2Fnewpage" . How ever this doesn't seem to function. At the begining i have hooked the login.event.post action where i override the response to for it to send me to a default page of my choosing. I though this was causing problems so i removed this action. Now after login, liferay remains on the login page. I was reading a post that was saying that liferay forgets to append the querry string. So i tried hooking the actual LayoutAction in my hook as folowing:

<struts-action>
		<struts-action-path>/portal/layout/LayoutAction</struts-action-path>
		<struts-action-impl>com.hooks.myhook.actions.HookedLayoutAction</struts-action-impl>
		
	</struts-action>


Than i create my class that extends the LayoutAction:


public class HookedLayoutAction extends LayoutAction{
	@Override
	public ActionForward execute(
			ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response)
		throws Exception {
// i copied the entier method from the layout class and made needed changes as suggested in the article above.  
}
}


How ever when i load the hook. Liferay does not go in throw my hooked action. Any sugestion of what am i doing wrong. I'm using Liferay 6.0.5 Comunity Edition

thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Hook on LayoutAction

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
You have to go to 'newpage' and remove guest access.

After that if you navigate to 'newpage' as an unauthenticated user, Liferay will redirect to the login page and then redirect you back to 'newpage' after you've successfully authenticated.
Mitko Zafirovski, modificado 11 Anos atrás.

RE: Hook on LayoutAction

Junior Member Postagens: 26 Data de Entrada: 01/03/12 Postagens Recentes
@David H Nebinger
Yes the new page does not have the guest view permission. The page only has a power user view perrmision and owner full permissions. Half of the scenraio is there. If i am not logged in and try to access the page i get redirected to the login screen and in the url i can see that liferay by it self adds the redirect parmetar.
http://localhost:8080/login?_58_redirect=%2Fweb%2Fguest%2Fnewpage

Then i login once i log in i stay at the login page with the same url as above in the browser. So basically liferay does not do the redirection after the login. I was trying to do the redirect manualy by hooking the login.event.post action and trying to get the parameter from the http request, but the parameter is not there. I was think it might be some of the configuration i added in the portal.ext.properties. From the default once i have the following overreeten:
auth.login.url
redirect.url.security.mode=domain
redirect.url.domains.allowed=
default.logout.page.path=
company.default.home.url

Is it possible one of these properties make stop liferay from redirecting? And if it is how do i go around that because these properties have to be overridden in my case. As i mentioned above i read that liferay forgets to append the querry string that is passes to it when its in the LayoutAction Automatic redirect to login forgets URL parameters.
Suyash Bhalekar, modificado 10 Anos atrás.

RE: Hook on LayoutAction

New Member Postagens: 24 Data de Entrada: 04/09/12 Postagens Recentes
Hi Mitko ,

Have you created any hook or ext or Listener to remove the view permission of page?
Or Have you manually removed the view permission of page from manage permission tab?

If you have done this case apart from manually, then kindly mention the steps to do so.

Thanks
Mitko Zafirovski, modificado 10 Anos atrás.

RE: Hook on LayoutAction

Junior Member Postagens: 26 Data de Entrada: 01/03/12 Postagens Recentes
Hello Suyash, we are manually editing the page permissions. If need to edit them programaticaly u can use:
ResourcePermissionLocalServiceUtil.setResourcePermissions
or
ResourcePermissionLocalServiceUtil.removeResourcePermission
Suyash Bhalekar, modificado 10 Anos atrás.

RE: Hook on LayoutAction

New Member Postagens: 24 Data de Entrada: 04/09/12 Postagens Recentes
Thanks Mitko,
I have created a Listener for Layout and on creation of page permissions are assigned as per required.
thumbnail
David H Nebinger, modificado 10 Anos atrás.

RE: Hook on LayoutAction

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
There is, I believe, a bug in one of the 6.1 CE releases (possibly ga2, don't remember) that the redirects were not working.
thumbnail
Nagendra Kumar Busam, modificado 11 Anos atrás.

RE: Hook on LayoutAction

Liferay Master Postagens: 678 Data de Entrada: 07/07/09 Postagens Recentes
I am not quite sure customization of struts action works for Liferay 6.0.5. According to link @ http://www.liferay.com/web/mika.koivisto/blog/-/blogs/overriding-and-adding-struts-actions-from-hook-plugins, we have support for this from Liferay 6.1.0 CE and backported to 6.0 EE SP2 so not available in 6.0.6 CE