Foros de discusión

redirect after login to page other than landing page

thumbnail
Philipp Kunz, modificado hace 12 años.

redirect after login to page other than landing page

New Member Mensajes: 10 Fecha de incorporación: 3/09/11 Mensajes recientes
Hi

I have a portal that shows some content to unauthenticated users, and some more and partially different content and more pages to authenticated users. Something like a shop where you have to be authenticated to see your pending orders and personal information but you can see items or the shopping cart as well anonymously. Some of the links which point to authentication-protected content are visible to guest users, too. It shall be possible to authenticate at any time by clicking a login link the login portlet of which redirects back to the current page which will then display personal information as well. It shall be possible as well to point the browser to any other page after successful login definable individually for every link.

I guess, I don't need autologin because I want the user to authenticate himself by password.

In the login portlet there is a request parameter "redirect" which works only under some conditions not obviously applicable to my scenario. In LoginAction.execute, line 88, the browser is redirected to the landing page without considering the "redirect" request parameter.
response.sendRedirect(themeDisplay.getPathMain());

Further below, on line 125, however, the "redirect" request parameter is evaluated, but I cannot figure out how to reach this line of code:
String loginRedirect = ParamUtil.getString(request, "redirect");

Furthermore, I want to be able to define links that point to a certain page other than the landing page or the current page via login. For example a link, that opens the login page and goes after successful login to the personal order history page which is not the default landing page nor necessarily the current page before clicking the login link.

How do I configure something like that? Any hint appreciated...
thumbnail
Subhasis Roy, modificado hace 12 años.

RE: redirect after login to page other than landing page

Expert Mensajes: 275 Fecha de incorporación: 20/01/12 Mensajes recientes
You can write a post login hook.

And based on the user community or user role you can create your own path and redirect him to your desired page.

Sample:

If user is administrator-

Your Hook Class code:

if(isAdminUser){
path = PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING)+"/guest";
}

response.sendRedirect(path);