Foren

Portal Struts action -> Portlet Struts action?

thumbnail
Andew Jardine, geändert vor 10 Jahren.

Portal Struts action -> Portlet Struts action?

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
I'm not even sure anymore that what I am trying to do is actually possible. Here is my flow.

1. User goes to sign in page (works)
2. User chooses either Google, Twitter or Facebook OAuth (works)
3. Struts actions via 2 hooks (one for fb, one for tiwtter+google) do the authentication (works)
4. User is forwarded to (custom) Registration page (NOT working)

Alternatively --
5. User chooses to Create Account (works)
6. User is taken to custom create account page (JSP override and struts action override done via 3rd hook) (works)

My issue. I can't figure out how to get the user from the OAuth handlers to the /login/create_account page. Can someone tell me how the hell I am supposed to be able to do this? I'm going crazy trying to get this to work and starting to lose a lot of faith. Please help.

Facebook liferay-hook.xml

<hook>
	<struts-action>
		<struts-action-path>/login/facebook_connect_oauth</struts-action-path>
		<struts-action-impl>com.xxxliferay.auth.facebook.FacebookOAuth</struts-action-impl>
	</struts-action>	
</hook>


Twitter + Google OAuth liferay-hook.xml

<hook>
	<portal-properties>portal.properties</portal-properties>
	<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
	<struts-action>
		<struts-action-path>/portal/twitter_login</struts-action-path>
		<struts-action-impl>com.mercatus.liferay.auth.twitter.TwitterOAuth</struts-action-impl>
	</struts-action>
	<struts-action>
		<struts-action-path>/portal/google_login</struts-action-path>
		<struts-action-impl>com.mercatus.liferay.auth.google.GoogleOAuth</struts-action-impl>
	</struts-action> 
</hook>


Custom Create Account liferay-hook.xml

<hook>
	<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
    <struts-action>
        <struts-action-path>/login/create_account</struts-action-path>
        <struts-action-impl>com.mercatus.liferay.auth.login.action.SproutsCreateAccountAction</struts-action-impl>
    </struts-action>	
</hook>


Trace I get in the log --
02:42:28,490 DEBUG [http-bio-8080-exec-268][RequestProcessor:172] Processing a 'GET' for path '/portal/layout'
02:42:28,491 DEBUG [http-bio-8080-exec-268][RequestProcessor:267] Looking for Action instance for class com.liferay.portal.action.LayoutAction
02:42:28,491 TRACE [http-bio-8080-exec-268][RequestProcessor:281] Returning existing Action instance
02:42:28,557 DEBUG [http-bio-8080-exec-268][PortletRequestProcessor:483] Getting request parameter path /login/create_account
02:42:28,558 DEBUG [http-bio-8080-exec-268][PortletRequestProcessor:505] Processing path /login/create_account
02:42:28,559 DEBUG [http-bio-8080-exec-268][RequestProcessor:172] Processing a 'GET' for path '/login/create_account'
02:42:28,561 DEBUG [http-bio-8080-exec-268][RequestProcessor:267] Looking for Action instance for class com.liferay.portlet.login.action.CreateAccountAction
02:42:28,561 TRACE [http-bio-8080-exec-268][RequestProcessor:281] Returning existing Action instance
02:42:28,562 ERROR [http-bio-8080-exec-268][PortletRequestProcessor:453] Forward does not exist
02:42:28,564 DEBUG [http-bio-8080-exec-268][StrutsUtil:57] Forward URI /common/themes/portal.jsp
02:42:28,565 DEBUG [http-bio-8080-exec-268][StrutsUtil:72] Forward path /html/common/themes/portal.jsp

Code I am trying to use to get the user there (in GoogleOAuth class)

PortletURL createAccountURL = PortletURLFactoryUtil.create( request, PortletKeys.LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE );

createAccountURL.setWindowState( WindowState.MAXIMIZED );
createAccountURL.setPortletMode( PortletMode.VIEW );

createAccountURL.setParameter( "saveLastPath", "0" );
createAccountURL.setParameter( "struts_action", "/login/create_account" );
createAccountURL.setParameter( "firstName", firstName );
createAccountURL.setParameter( "lastName", lastName );
createAccountURL.setParameter( "emailAddress", emailAddress );
createAccountURL.setParameter( "googleId", googleId);
createAccountURL.setParameter( "googlePlusLink", googlPlusLink);
						
redirect = createAccountURL.toString();
					        
response.sendRedirect( redirect );
thumbnail
Mohammed Azam, geändert vor 10 Jahren.

RE: Portal Struts action -> Portlet Struts action?

Regular Member Beiträge: 159 Beitrittsdatum: 06.11.09 Neueste Beiträge
Hi Andrew


What I could understand from your question is that you want to redirect to page of Login from your custom Controller class.

You can use the below code for redirection. Change the "sturts_action" value accordingly

                  PortletURL loginURL = LoginUtil.getLoginURL(
				request, themeDisplay.getPlid());
			loginURL.setParameter("struts_action", "/login/userlogin");
			loginURL.setParameter("login", login);

			redirect = loginURL.toString();
                      actionResponse.sendRedirect(redirect);


Hope this helps!
thumbnail
Andew Jardine, geändert vor 10 Jahren.

RE: Portal Struts action -> Portlet Struts action?

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Mohammed,

Thanks for taking the time to write back. That was not quite it but I have managed to solve my problem. My issue was that I kept getting Forward does not exist when transitioning from the /portal/[provider]_login struts action to the /login/create_account struts portlet action. I thought maybe that this meant that you couldn't do that but careful debugging led me to a different solution. My custom create account action was EXTENDING BaseStrutsPortletAction. As such I had not overridden the render method and so it was trying to forward to "null". I changed this ti use the StrutsPortletAction interface and then for the render method did the originalStrutsPortletAction.render( ... );. Problem solved.

Thanks again.

Mohammed Azam:
Hi Andrew


What I could understand from your question is that you want to redirect to page of Login from your custom Controller class.

You can use the below code for redirection. Change the "sturts_action" value accordingly

                  PortletURL loginURL = LoginUtil.getLoginURL(
				request, themeDisplay.getPlid());
			loginURL.setParameter("struts_action", "/login/userlogin");
			loginURL.setParameter("login", login);

			redirect = loginURL.toString();
                      actionResponse.sendRedirect(redirect);


Hope this helps!