Fórum

Login Portlet: "Create Account" should not maximize the portlet

thumbnail
Dave Kliczbor, modificado 12 Anos atrás.

Login Portlet: "Create Account" should not maximize the portlet

Junior Member Postagens: 77 Data de Entrada: 12/07/11 Postagens Recentes
Hello all of you out there,

I'm customizing the Login Portlet of LR 6.1.0 CE using the hook plugin approach. So far, I copied and customized some jsps in html/portlet/login/, namely login.jsp, navigation.jsp, create_account.jsp and css/main.jsp. Works nicely, apart from one little glitch: Some redirects set WindowState.MAXIMIZED (a.k.a. p_p_mode=maximized) instead of WindowState.NORMAL.

In one instance, I don't seem to be able to ferret WindowState.MAXIMIZED out without introducing another problem.

Okay, now the details...

Our registration workflow should look like this: New user clicks on "Create Account", fills the form, submits it, is redirected to the login page which shows a message saying his autogenerated password is sent to his email address (we want that part as email address verification). Then he checks his email, finds the password and is able to login for the first time ... and is now required to set a new password. This workflow works ... almost. The redirect to the login page inserts WindowState.MAXIMIZED for the login portlet. Do not want.

This workflow does not seem possible while keeping WindowState.NORMAL ... I dug deeper into it and found com.liferay.portlet.login.action.CreateAccountAction.sendRedirect(..). From the code I learned that I could set a redirect URL in a hidden form field in create_account.jsp (which would enable me to generate the correct URL to display the login portlet as NORMAL), BUT then the new user would be automatically logged in without having to check his email (see the source from line 300 to 313).

Seeing that sendRedirect(..) calls com.liferay.portlet.login.util.LoginUtil.getLoginURL(..) to generate the redirect URL (in case no redirect URL is given in the hidden form field), I looked into the source and found a hardcoded feature: portletURL.setWindowState(WindowState.MAXIMIZED); ... and following the path of this property up to the user's browser, I did not find any more points where I could meddle with it (apart from changing the sources) *grumblemumble*

This leaves me with various questions, to which I hope to find an answer here in the forums:
  • Do I have to create an EXT plugin to fix that behaviour? (Sorry to ask that, but up until now, I only checked what EXT is; I never used it)
    • If so, what are the minimal steps necessary to overwrite one of the classes mentioned above?
    • Can I overwrite only one method instead of a whole class? I'd rather like not to "freeze" the other methods in case they're updated in the upcoming release process of LR 6.1.
  • Is there a possible workaround? Like logging the user out again, but retaining the message that his password has been sent to his email address?
  • Is there another workflow possible thats roughly analogous to the one outlined above? We do need the email verification process before the user is logged in for the first time.
  • Can this be considered a bug? Should I create a bug report, then?
Thanks in advance for all answers to any of these questions ...
- Dave
thumbnail
Elijah Mangason, modificado 11 Anos atrás.

RE: Login Portlet: "Create Account" should not maximize the portlet

Junior Member Postagens: 65 Data de Entrada: 14/05/12 Postagens Recentes
Dave Kliczbor:


...From the code I learned that I could set a redirect URL in a hidden form field in create_account.jsp (which would enable me to generate the correct URL to display the login portlet as NORMAL), BUT then the new user would be automatically logged in without having to check his email (see the source from line 300 to 313)....

Hello Dave Kliczbor,
Our workflow requires that users be logged in automatically from CreateAccount, which you didn't want to happen, as described above. Do you remember where you put the redirect in create_account.jsp file, and also the syntax? Any info would be much appreciated.
Thanks.
thumbnail
Dave Kliczbor, modificado 11 Anos atrás.

RE: Login Portlet: "Create Account" should not maximize the portlet

Junior Member Postagens: 77 Data de Entrada: 12/07/11 Postagens Recentes
Hmmm ... I'm unsure what information you really need.

The redirect from the create account form, anyway, is set in create_account_form.jsp, and this is how I solved it:

[..]
<%
PortletURL loginURL = LoginUtil.getLoginURL(request, themeDisplay.getPlid());
loginURL.setWindowState(WindowState.NORMAL);
String redirect = loginURL.toString();
[..]
%>
<portlet:actionurl var="createAccountURL">
	<portlet:param name="saveLastPath" value="1" />
	<portlet:param name="struts_action" value="/login/create_account" />
	<portlet:param name="p_p_state" value="normal" />
</portlet:actionurl>

<aui:form action="<%= createAccountURL %>" method="post" name="fm">
	<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.ADD %>" />
	<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
[..]
</aui:form>


Maybe it helps you...
thumbnail
Elijah Mangason, modificado 11 Anos atrás.

RE: Login Portlet: "Create Account" should not maximize the portlet

Junior Member Postagens: 65 Data de Entrada: 14/05/12 Postagens Recentes
Hello Dave,

Thank you for responding. What I need to know is how you accomplished this:

... BUT then the new user would be automatically logged in without having to check his email ...

Our workflow requires that users be logged in automatically from CreateAccount without checking their email. I realize that is NOT the behaviour you wanted, but we need it!! Do you remember how you did it?

Elijah M.
thumbnail
Dave Kliczbor, modificado 11 Anos atrás.

RE: Login Portlet: "Create Account" should not maximize the portlet

Junior Member Postagens: 77 Data de Entrada: 12/07/11 Postagens Recentes
Okay, I got your point emoticon

From the code I linked in my first post, you see that the request generated by the create account form only has to send a field named "redirect" to log the User in and redirecting him to the page of your choice.

Therefore, you only need to set the hidden redirect form field in create_account.jsp to your choice.

Instead of:
<aui:form action="<%= createAccountURL %>" method="post" name="fm">
	<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.ADD %>" />
	<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
</aui:form>

just use:
<aui:form action="<%= createAccountURL %>" method="post" name="fm">
	<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.ADD %>" />
	<aui:input name="redirect" type="hidden" value="/web/guest/home" />
</aui:form>

or whatever you need (I'm unsure whether I wrote that last line myself or if it is standard code). Anyhow, you'd be best off to create a hook plugin to overwrite create_account.jsp, if you did not already do that ...
thumbnail
Elijah Mangason, modificado 11 Anos atrás.

RE: Login Portlet: "Create Account" should not maximize the portlet

Junior Member Postagens: 65 Data de Entrada: 14/05/12 Postagens Recentes
I wrote a hook to customize the login/create account process. It works great, except that I couldn't get it to bypass the actual login.jsp screen to automatically authenticate the new user without breaking the flow of the process. Thanks for your response! I'll give it a try.