Fórum

Good approach for a redirect portlet/servlet/site

Matthew K., modificado 6 Anos atrás.

Good approach for a redirect portlet/servlet/site

Junior Member Postagens: 74 Data de Entrada: 31/08/15 Postagens Recentes
Hello!
I often come into a situation where I need something like a redirect portlet which I can put on a page. For example there is often the requirement that users get redirected to a certain page when they visit the login page. So guest users shall see the login portlet but already logged in users will be redirected. There are several things I tried but I haven't found a perfect solution for this. For example I created a portlet that I put on that site which performs a javascript redirect. The disadvantage is that the page is loaded normally and I only get redirected when the portlet is finished with rendering which will cause something like a flickering effect. Another thing I tried was to create a servlet filter with the url pattern set to the login page. The disadvantage here is that you have to hardcode the friendly urls (even for each locale) into the servlet xml or into your java code. So if an admin changes the friendly url of the login page or if someone wants to have a redirect on another page as well, I always have to change and redeploy the servlet filter.
As you might notice, a good solution for this rather simple problem is kind of difficult. Any other ideas?
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Good approach for a redirect portlet/servlet/site

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
For login users, Liferay uses a "landing page" concept where you can automagically redirect logged in users to appropriate places. Since you'll write this as a Java component, you have total flexibility in generating the logic to determine where each user needs to be redirected.
Matthew K., modificado 6 Anos atrás.

RE: Good approach for a redirect portlet/servlet/site

Junior Member Postagens: 74 Data de Entrada: 31/08/15 Postagens Recentes
I think you didn't completely understand my question. I know that I can use a custom landing page action for redirecting users after login, but what happens if I use your solution and I visit the login page? Correct! The sign up portlet is shown with the text "You are logged in as Joe Bloggs" (or something like that). I dont want that already logged in users see that page. When they visit this page they should automatically be redirected to the landing page so that the login page is kind of invisible for authenticated users. That's why I need an approach for something like a redirect portlet that I can put on that page.
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Good approach for a redirect portlet/servlet/site

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Hmm, I'm not sure there's a way to check on current page and redirect if user is already authenticated.

Normally we don't make the login page appear as part of navigation, so this is not typically an issue.