Fórum

redirect to custom page after login

thumbnail
Habib Zare, modificado 8 Anos atrás.

redirect to custom page after login

Junior Member Postagens: 58 Data de Entrada: 28/10/12 Postagens Recentes
hi,
there is a page in /html/portal/verify_email_address.jsp
i have created other one /html/portal/verify_mobile_number in my hook project.
i want verify user mobile when the user log in to portal.
in my ext project i have extend the com.liferay.portal.struts.PortalRequestProcessor
and i add this String to the fields of class.
	private static final String _PATH_PORTAL_VERIFY_PHONE_NUMBER = "/portal/verify_phone_number";


and after verifiing email address i add verified phone number


                           // Authenticated users should have a verified phone number

			if ((userExt != null) && !userExt.isPhoneNumberVerificationComplete()) {
				if (path.equals(_PATH_PORTAL_UPDATE_PHONE_NUMBER)) {
					return _PATH_PORTAL_UPDATE_PHONE_NUMBER;
				}

				return _PATH_PORTAL_VERIFY_PHONE_NUMBER;
	}


in the struts-config-ext.xml i add :

<struts-config>
	<action-mappings>
		<action path="/portal/update_phone_number" type="com.liferay.portal.action.UpdatePhoneNumberAction">
			<forward name="portal.update_phone_number" path="portal.update_phone_number" />
		</action>
		<action path="/portal/verify_phone_number" type="com.liferay.portal.action.VerifyPhoneNumberAction">
			<forward name="portal.verify_phone_number" path="portal.verify_phone_number" />
		</action>
	</action-mappings>
</struts-config>



when i create account and login the portal not going to the /portal/verify_phone_number.jsp;
please help me.
thx.
thumbnail
Amos Fong, modificado 8 Anos atrás.

RE: redirect to custom page after login

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
I think that code looks correct. Do you know if it's actually entering your if block in PortalRequestProcessor? I assume it's in the processPath() method?

Where does the user actually go after login?

Also, if you already haven't, I think you also need to modify tiles-defs-ext.xml to add your jsp path definition there.
thumbnail
Habib Zare, modificado 8 Anos atrás.

RE: redirect to custom page after login

Junior Member Postagens: 58 Data de Entrada: 28/10/12 Postagens Recentes
Thanks Amos Fong .
I had forgotten that I add below tags in tiles-defs-ext.xml


	<definition name="portal.update_phone_number" extends="portal">
		<put name="title" value="update-phone-number" />
		<put name="content" value="/portal/update_phone_number.jsp" />
	</definition>
	<definition name="portal.verify_phone_number" extends="portal">
		<put name="title" value="verify-phone-number" />
		<put name="content" value="/portal/verify_phone_number.jsp" />
	</definition>

thumbnail
Habib Zare, modificado 8 Anos atrás.

RE: redirect to custom page after login

Junior Member Postagens: 58 Data de Entrada: 28/10/12 Postagens Recentes
now i want to go to the page /portal/verify_phone_number.jsp from the link that i provided in my account page that shows in dialog page.


<liferay-portlet:renderurl var="phoneNumberVerifyUrl">
       <liferay-portlet:param name="struts_action" value="/portal/verify_phone_number" />
</liferay-portlet:renderurl>

	
<a href="<%=phoneNumberVerifyUrl.toString()%>">verify-phone-number</a>


why this is not working?
thumbnail
Amos Fong, modificado 8 Anos atrás.

RE: redirect to custom page after login

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
That's because your action is a portal struts action and doesn't belong this the my account portlet.

You can create a URL to it something like this:
<%= themeDisplay.getPathMain() + "/portal/update_email_address" %>
thumbnail
Habib Zare, modificado 8 Anos atrás.

RE: redirect to custom page after login

Junior Member Postagens: 58 Data de Entrada: 28/10/12 Postagens Recentes
thanks
I put this code in /html/portlet/users_admin/user/details.jsp


<aui:a href="<%=themeDisplay.getURLPortal()+themeDisplay.getPathMain() +&quot;/portal/verify_phone_number&quot;%>" label="verify-your-unverified-phone-number" title="verify-your-unverified-phone-number" />


when i click the link it goes to verify_phone_number page in dialog window. but i want to close the dialog window and render to verify_phone_number.
is it possible to do that without javascript?
thumbnail
Amos Fong, modificado 8 Anos atrás.

RE: redirect to custom page after login

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
I think that's going to require some javascript.
thumbnail
Habib Zare, modificado 8 Anos atrás.

RE: redirect to custom page after login

Junior Member Postagens: 58 Data de Entrada: 28/10/12 Postagens Recentes
hello Amos Fong .

I solved my problem like below :


                              &lt;%
					String hrefStr="javascript:" + renderResponse.getNamespace() + "closePopupAndVerify();" ;
				%&gt;

 				
					<aui:a href="<%=hrefStr%>" label="verify-your--phone-number" title="verify-your-phone-number" />
				

				<aui:script>		
					Liferay.provide(
					window,
					'<portlet:namespace />closePopupAndVerify',
						function() {
						Liferay.Util.getOpener().location.href = '&lt;%=themeDisplay.getURLPortal()+themeDisplay.getPathMain() +"/portal/verify_phone_number"%&gt;';
						var dialog = Liferay.Util.getWindow();
						dialog.hide();
						},
			        ['liferay-util-window']
					);
				</aui:script>					


This may help someone.
Thanks.
thumbnail
Habib Zare, modificado 8 Anos atrás.

RE: redirect to custom page after login

Junior Member Postagens: 58 Data de Entrada: 28/10/12 Postagens Recentes
For me i can delete this line of javascript code (because, the parent window will be refreshed to the new address.):

var dialog = Liferay.Util.getWindow();
dialog.hide();


This is for closing current dialog window.
Enjoy.