Foros de discusión

[6.1] closing Iframe login popup after successful login

Nicolas Herbaut, modificado hace 11 años.

[6.1] closing Iframe login popup after successful login

New Member Mensajes: 6 Fecha de incorporación: 2/08/12 Mensajes recientes
Hello,

I'm pretty new to liferay to sorry if this question is trivial.

I need to put the login in a popup iframe (so that the whole page is not reloaded if an action is triggered from the login - like forgot password or something)

So i successfully implemented the iframe popup simply by following the indications from http://www.liferay.com/community/wiki/-/wiki/Main/Using+Pop-up+in+Liferay by using some javascript on a button on my theme
AUI().ready("liferay-portlet-url","node", function(A) {
	Liferay.provide(window, 'showSignInPopup', function() {
		var instance = this;

		var url = Liferay.PortletURL.createRenderURL();
		url.setPortletId("58");
		url.setWindowState("pop_up");

		Liferay.Util.openWindow({
			cache : false,
			dialog : {
				destroyOnClose : true,
				align : Liferay.Util.Window.ALIGN_CENTER,
				modal : true,
				after : {
					render : function(event) {
						this.set('y', this.get('y') + 50);
					},
					destroy : function(event){
						window.location.reload();
					}
				},
				width : 500
			},
			dialogIframe : {
				id : 'SignInPopupIframe',
				uri : url.toString()
			},
			title : 'Sign-in',
			uri : url.toString()
		});
	}, [ 'liferay-util-window' ]);

	A.one(".login-button").on('click', function(e) {
		showSignInPopup();
	});
	
	
});


However my problem is that I don't know how to close the popup after a successfull login, and I don't see any forum hint on how to do that, not mentionning the documentaion.

Can any one help? Thanks!
Nicolas Hrbt, modificado hace 11 años.

RE: [6.1] closing Iframe login popup after successful login

New Member Mensajes: 6 Fecha de incorporación: 2/08/12 Mensajes recientes
no one has a clue? is there something wrong / unclear with my question?
Oliver Bayer, modificado hace 11 años.

RE: [6.1] closing Iframe login popup after successful login

Liferay Master Mensajes: 894 Fecha de incorporación: 18/02/09 Mensajes recientes
Hi Nicolas,

I don't have a complete working solution for your problem but maybe you can use the following hints as a starting point. If you take a look at the way Liferay is handling popups you will maybe find a solution. I would use the "html \ portlet \ journal \ edit_article.jsp" and the javascript method "selectTemplate(...)" as a reference. The last parameter is the dialog object which is getting closed and the form submitted if the user confirms the popup message.

HTH Oli
Jignesh Majmudar, modificado hace 10 años.

RE: [6.1] closing Iframe login popup after successful login

Junior Member Mensajes: 36 Fecha de incorporación: 7/05/10 Mensajes recientes
Hi Nicolas,

Have you found any solution to close the popup after sign in?

I am facing the same issues.

please provide the solution if you or anybody have for the same.
thumbnail
Rahul Rabhadiya, modificado hace 10 años.

RE: [6.1] closing Iframe login popup after successful login

Junior Member Mensajes: 57 Fecha de incorporación: 14/06/13 Mensajes recientes
I have same issue like you. Have u got any solution if yes then please help me .. emoticon
Laurent CHARLOIS, modificado hace 10 años.

RE: [6.1] closing Iframe login popup after successful login

New Member Mensajes: 6 Fecha de incorporación: 17/10/12 Mensajes recientes
Hi,

We found a solution with Nicolas.

It's a little bit magic but :
  • it works very well
  • i can explain you how it works


We inject the pop-up at the theme level but i think you can do this at other place.

That's the code in our velocity template from the theme project.

		#set($fast_login_id = "164") ## $PortletKeys.FAST_LOGIN
		#set($render_phase_value = "RENDER_PHASE") ## $PortletRequest.RENDER_PHASE
		#set($sign_in_url = $portletURLFactory.create($request, $fast_login_id , $themeDisplay.getPlid(), $render_phase_value))
		$sign_in_url.setWindowState("POP_UP")
		$sign_in_url.setPortletMode("VIEW")
		$sign_in_url.setParameter("saveLastPath", "0")
		$sign_in_url.setParameter("struts_action", "/login/login")
		
		<script type="text/javascript">
			// it will be used in the 2nd part.
                        function _home_page_afterLogin(emailAddress, anonymousAccount) {
                                window.location.reload(false);
                        }

                        // open pop-up containing the login form.
			function signInDialog() {
				window.namespace = '_home_page_';
				window.randomNamespace = '_home_page_';
				Liferay.Util.openWindow(
						{
							dialog: {
								centered: true,
								modal: true
							},
							id: '_home_page_signInDialog',
							title: Liferay.Language.get('sign-in'),
							uri: "$sign_in_url.toString()"
							}
						);
				}
		</script>	



How it works?

In fact, if you look at the file named html/portlet/login/login_redirect.jsp there is some script that call a method named ' randomNamespace + "afterLogin" '.
You can do what you want in this method (we use to avoid the page to be reloaded) and after calling this "afterLogin" method the popup is killed. To kill the pop-up there is a 'closeWindow' event that is fired by login_redirect.jsp with id param having ' namespace + "signInDialog" ' value. It's for that the pop-up is created with the id '_home_page_signInDialog'.

I hope it's help you.

Sorry if my explanation are not fully right, we do this a few months ago.

Laurent.
thumbnail
Rahul Rabhadiya, modificado hace 10 años.

RE: [6.1] closing Iframe login popup after successful login

Junior Member Mensajes: 57 Fecha de incorporación: 14/06/13 Mensajes recientes
Thank you very much .it is working . . it is really helpful. emoticon
Laurent CHARLOIS, modificado hace 10 años.

RE: [6.1] closing Iframe login popup after successful login

New Member Mensajes: 6 Fecha de incorporación: 17/10/12 Mensajes recientes
You're welcome.
I'm happy to be able to help someone on Liferay!
thumbnail
shivam aggarwal, modificado hace 10 años.

RE: [6.1] closing Iframe login popup after successful login

Regular Member Mensajes: 122 Fecha de incorporación: 18/01/12 Mensajes recientes
Thanks a lot man!! works like anything