1. The login div is shown at the bottom for logged user. I changed it so footer is returned only for anonymous user.
2. My "user/login" link has destination query string to send the user back to the original page where they click the login link. I change the javascript to be compatible with this use case. It should work the same as before.

you can see this working at http://zen.hddigitalworks.com/node/198, click the login link at the upper right, use user name "visitor", passoword "123". After login, you should be back to that page instead of going the /user.

Thanks for the module.

CommentFileSizeAuthor
fancy_login.patch1.53 KBmattyoung
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mattyoung’s picture

BTW, it works fine in 'user/password' and 'user/register' paths.

Try login from http://zen.hddigitalworks.com/user/password or http://zen.hddigitalworks.com/user/register

Jaypan’s picture

Thanks for taking care of this! Much appreciated.

I'm going to create an administration page that lets the user decide whether they want to be forwarded to the site's front page after login, or if they want to stay on the page they are on. So can you give me a quick run down on what this means:

$("a[href^='" + Drupal.settings.basePath + "user/login']").each(function()
{
	$(this).click(function()
	{
	    $("#fancy_login_login_box form").attr("action", $(this).attr("href"));
		fancyLogin.showLogin();
		return false;
	});
}

I was looking at it, and didn't really get what you have done there. Thanks.

mattyoung’s picture

>I'm going to create an administration page that lets the user decide whether they want to be forwarded to the site's front page after login

No, don't do that. You should just leave that decision to whoever created the 'user/login' link to decide. And this is what my patch accomplish. Let me explain how this works.

$("a[href^='" + Drupal.settings.basePath + "user/login']")

This looks for any <a> tag with href attribute *begins with* 'user/login' (note that ^= instead of =). This will match href like 'user/login?destination=<front>'. (I'll explain what this does later).

Inside the click event handler:

$("#fancy_login_login_box form").attr("action", $(this).attr("href"));

this replace the fancy_login form's action url with the <a> tag href the user click on.

With this, fancy_login does not need to care about where to send the user to after login anymore. That decision is with the <a> tag login link. Those links can be like:

'user/login?destination=node/12345' this will send the user back to the node page 12345 after login
'user/login?destination=<front>' this will send the user to the front page after login
'user/login' this will go to the user page

Where is no way you can cover every case and you shouldn't. With my patch, people are free to do whatever they want with their login link and fancy_login will adapt to it.

Try it at my test site http://zen.hddigitalworks.com, user 'visitor', password '123'

Click on any link on that page, then click login at the upper right, you will see the page come back to the same place after login. You don't need to change fancy_login anymore.

If people ask you about sending them to the front page or where ever else, just tell them to set the destination query string in their login link. This is how they should do it without fancy_login and it shouldn't be any different with fancy_login.

Jaypan’s picture

Nice, thanks for the explanation, I got it. I'll commit it today!

Jaypan’s picture

Status: Fixed » Active

Edit: Realized the post contents didn't work at all.

Jaypan’s picture

New code applied in beta4

Jaypan’s picture

Status: Active » Fixed

Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.