I have a problem trying to fire up an autologin class in Liferay CE 6.1.1 when performing a redirection from a custom action method. Let me explain the scenarios.
Functional scenario 1: direct POST
action
Let's say I have a public page A with a login form (with username and password), an autologin class to perform some checks and a private page B to show some data after proper authentication.
I have a JSP with the login form in a portlet deployed in public page A, as follows (this is an oversimplified version):
<form method="post" action="https://localhost:4444/path/to/private/page/b">
<input id="username" type="text" />
<input id="password" type="password" />
<input type="submit" />
</form>
When the submit button is pressed, the autologin class is fired up and, if the checks are passed, the user lands in the private page B, as intended.
Non-functional scenario #2: redirection through custom action
The previous scenario doesn't work in certain situations where a previous authentication has been performed, so I need to add some checks before the autologin gets executed.
I thought that creating a custom action linked to the form was a good idea, so I rewrote the form as follows:
<portlet:actionUrl name="actionLogin" var="urlActionLogin" />
<form method="post" action="${urlActionLogin}">
<input id="username" type="text" />
<input id="password" type="password" />
<input type="submit" />
</form>
In the main class of the portlet deployed in public page A, we need a method to deal with the form action (oversimplifying again):
public void actionLogin (ActionRequest request, ActionResponse response) {
if (testsArePassed ( )) {
response.sendRedirect ("https://localhost:4444/path/to/private/page/b");
} else {
// Error page.
}
}
Putting aside the passing of parameters (I used copy-request-parameters
in portlet.xml
to ensure that), all I get is the same public page A again, with no autologin and with an URL like:
I guess I'm making some kind of conceptual mistake here, but, what's the reason why the autologin is not fired up in the second scenario, allowing navigation to private page B?
Thanks!
Assuming you are using Generic Portlet.
After every processAction doView method is called before rendering the jsp page. So handle it this way. Goto Liferay Forum for more details.