Fórum

Default Landing Page Not Always Working

Bradley Bertrim, modificado 12 Anos atrás.

Default Landing Page Not Always Working

New Member Postagens: 13 Data de Entrada: 22/07/10 Postagens Recentes
To set the stage, here is what I'm doing.

We are using Liferay 5.2.3 and simply require having users directed to an Organization's private page if they are a member of that organization. If they are not a member of any organization we are forwarding the user to their private community.

This is accomplished simple enough by creating a hook setting the following in portal.properties
auth.forward.by.last.path=true
default.landing.page.path=
login.events.post=ca.queensu.liferay.plugin.CustomLoginPostAction


My CustomLoginPostAction class handles all the logic for the login and calls a utility method (shown below) to set the LAST_PATH attribute in the session.

private void setLandingPageAttribute(HttpServletRequest request, String path) throws Exception{                      
    Class classLastPath = PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.struts.LastPath");
    Constructor constructorLastPath = classLastPath.getConstructor(new Class[] {String.class, String.class});        
        
    request.getSession().setAttribute(
            "LAST_PATH"
          , constructorLastPath.newInstance(new Object[] {request.getContextPath(), path}));        
    }
}


Now here is where my problem comes in. This works perfectly on my local machine, however, in our dev environment it always directs the user to /web/guest (the company.default.home.url value) as a landing page instead of the value set in the LAST_PATH attribute.

Through logging I have verified that the value being stored in the session attribute is correct.

I have tried setting company.default.home.url to a blank value in portal-ext.properties, which results in an infinite redirection loop when logging in.

I feel the solution is a very simple one and possibly a property/configuration change but I'm at a loss as to where to look next.

Any help/advice would be greatly appreciated,
Bradley
thumbnail
Mani kandan, modificado 12 Anos atrás.

RE: Default Landing Page Not Always Working

Expert Postagens: 492 Data de Entrada: 15/09/10 Postagens Recentes
Did you follow correct procedure which is mentioned in this link and here?
Bradley Bertrim, modificado 12 Anos atrás.

RE: Default Landing Page Not Always Working

New Member Postagens: 13 Data de Entrada: 22/07/10 Postagens Recentes
Mani kandan:
Did you follow correct procedure which is mentioned in this link and here?


I have, baring in mind I am using a hook and therefore don't have access to portal-impl directly. Hence, the use of reflection to instantiate a LastPath object to be stored as a session attribute.

Also, as a side note, what baring does setting the "p_l_id" attribute to "PRI.3.1" have? In my testing yesterday I've found that with or without it, it does not effect the behavior.

Bradley
Bradley Bertrim, modificado 12 Anos atrás.

RE: Default Landing Page Not Always Working

New Member Postagens: 13 Data de Entrada: 22/07/10 Postagens Recentes
I followed a hunch and disabled our auto-login hook as well as the security that relies on it in our dev environment. This caused the login process to occur as I would expect and mirror the behavior observed on my local machine.

After doing some research I found these threads http://www.liferay.com/community/forums/-/message_boards/message/291348 and http://www.liferay.com/community/forums/-/message_boards/message/736818 which lead me to believe that when an auto-login hook is employed the login.events.post action occurs after the the request has been processed and therefore too late for the LOGIN_PATH attribute to have any effect.

I will have to resort to creating a redirect in the auto-login hook, which isn't optional but still accomplishes the desired effect.

If anyone knows of a way, without resorting to altering the source code, to use the LOGIN_PATH variable instead of forcing a redirect and/or keeping the landing behavior in a post login hook to help maintain better cohesion I would greatly appreciate your input.

Bradley
Shiho Pingali, modificado 11 Anos atrás.

RE: Default Landing Page Not Always Working

New Member Postagens: 12 Data de Entrada: 20/12/11 Postagens Recentes
We have the same issue. We are setting the LAST_PATH in session from login hook (PostLoginAction) to do redirect but is ignored when the Home URL is set in Portal Settings (Control Panel). If I remove the Home URL, the redirect works. When you are testing this, make sure to start new session by closing the browser or clearing browser cache (active login, cookies, etc.). If the session contains LAST_PATH from your previous session, the redirect works.
thumbnail
Tejas Kanani, modificado 11 Anos atrás.

RE: Default Landing Page Not Always Working

Liferay Master Postagens: 654 Data de Entrada: 06/01/09 Postagens Recentes
thumbnail
Abhed Dekavadiya, modificado 9 Anos atrás.

RE: Default Landing Page Not Always Working

Junior Member Postagens: 74 Data de Entrada: 05/10/10 Postagens Recentes
Hi Tejas,

Thanks for the free plugin 'custom landing page hook'.
I used it for a client and I can confirm that it doesn't work when 'Home URL' (under Control Panel -> Configurations -> Portal Settings -> Navigation) is there. As stated by Shiho, make sure to clear browser cache.

Please let me know, if there's a solution for this.
I used the hook on LR-6.2.0 with some specific customization for organizationPrivatePages redirection.

regards,
Abhed Dekavadiay
thumbnail
Tejas Kanani, modificado 9 Anos atrás.

RE: Default Landing Page Not Always Working

Liferay Master Postagens: 654 Data de Entrada: 06/01/09 Postagens Recentes
Hi Abhed,

Can you set log level to DEBUG in Custom Landing Page Hook war(/WEB-INF/classes/log4j.xml) and re-deploy in order to get debug level logs ?
You'll get logs in {Liferay HOME}\logs\custom-landing-page-hook.*.log file. Can you check and share the logs if getting any issues ?

Thanks,
Tejas
thumbnail
Daniel Tyger, modificado 9 Anos atrás.

RE: Default Landing Page Not Always Working

Regular Member Postagens: 105 Data de Entrada: 06/02/13 Postagens Recentes
Shiho Pingali:
We have the same issue. We are setting the LAST_PATH in session from login hook (PostLoginAction) to do redirect but is ignored when the Home URL is set in Portal Settings (Control Panel). If I remove the Home URL, the redirect works. When you are testing this, make sure to start new session by closing the browser or clearing browser cache (active login, cookies, etc.). If the session contains LAST_PATH from your previous session, the redirect works.


Thank you Shiho for sharing this bit and Abhed for raising the issue as it pertains to the LR Marketplace Custom Landing Page Hook supplied by Tejas / OS4L mentioned in this thread and another popular one: https://www.liferay.com/community/forums/-/message_boards/message/38094402. And, many thanks to Tejas for sharing his hook via the MarketPlace.

With ~12,000 views, and a lot of trial and error and testing, I wanted to lend credence to the issue that Liferay's HOME URL setting in Portal Configuration >> Portal Settings >> Home URL overrides any custom attempts to control WebKeys.LAST_PATH

If you are trying to get the OS4L hook or any LAST_PATH override hook to work, empty this field, and restart browser / cache, redeploy, etc and you should see then your hook start to work.

I suppose we need to build into our hooks a final landing page that would reflect the default, if no custom directives were met by an incoming user....