I think it makes sense to log a user in after they create an account, if account does not require approval. Since the point of this module is to make creating an account an easy... I've patched this on my own site and will upload if there's interest.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rhughes’s picture

If you could do that, that would be great.

I am also looking for a really simple login process.

I am a Drupal newbie so if you could provide any information as to where and how to patch that would be awesome.

heydemo’s picture

FileSize
766 bytes

Ok, here's the patch. So basically you would put this in your email_registration directory and type:
patch < email_registration-login.patch

Remember to back up before applying patches. And read this for more info:
http://drupal.org/patch/apply

heydemo’s picture

Status: Active » Needs review
Christopher Herberte’s picture

Does this patch provide the existing, built-in functionality for logging users in immediately after registration at admin/user/settings ?

... "With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration."

mdcook’s picture

Patch worked. Thank you!

heydemo’s picture

Chris, not sure I understand. As email registration module stands, user is *logged out* after registering. This patch logs user in, as long as email verification is not required. It is as simple as setting the global user object to the account parameter of hook_user.

greggles’s picture

I looked through the code in user.module for a little while and I'm not sure why we should have to do this in email_registration.module instead of just letting user.module "do the right thing." But, I'm very new to email_registration module so perhaps it is my lack of knowledge.

@heydemo - could you explain this a bit more? I agree that we should be respecting that core setting.

Christopher Herberte’s picture

Category: feature » bug
Status: Needs review » Reviewed & tested by the community

I can confirm that without this patch email_registration will not work as it should with "Require e-mail verification when a visitor creates an account" unticked.

Christopher Herberte’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Committed to 6.x.1.x-dev

ericbroder’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
Priority: Normal » Major
Status: Closed (fixed) » Needs work

Sorry to open up an old issue, but I think we may be missing an important step here.

It is as simple as setting the global user object to the account parameter of hook_user.

Don't we also need to call either user_external_login or user_authenticate_finalize? Otherwise the auto-login function in this module will not properly invoke the login functionality happening in other modules.

For example, I'm having a conflict with Secure Pages Hijack Prevention module. SPHP contains the following code:

/**
 * Implementation of hook_user().
 */
function securepages_prevent_hijack_user($op, &$edit, &$user, $category = NULL) {
  switch ($op) {
  case 'login':
    _securepages_prevent_hijack_cookie();
    break;

  case 'after_update':
    // Regenerate our cookie after password changes.
    if (!empty($edit['pass'])) {
      _securepages_prevent_hijack_cookie();
    }
    break;
  }
}

The login hook is not getting invoked by Email Registration module upon auto-login, as it should.

In my particular use case I'm creating a new user by calling user_save in my custom module, so I'm not using the usual user/register form.

greggles’s picture

Title: Log user in after registration » Log user in after registration - call user_external_login or user_authenticate_finalize

Yep, makes sense to me. Does this also affect 7.x?

greggles’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Yes, it appears it does so let's fix it there first and then backport.

greggles’s picture

Title: Log user in after registration - call user_external_login or user_authenticate_finalize » Log user in after registration - call user_authenticate_finalize / user_login_finalize
Status: Needs work » Needs review
FileSize
1.51 KB

user_external_login is for modules that authenticate against another system, so I think that user_authenticate_finalize is the right function to use here.

user_authenticate_finalize is user_login_finalize in D7.

Attached is a patch to add it to d7 and add some tests to be more confident that it works.

greggles’s picture

Title: Log user in after registration - call user_authenticate_finalize / user_login_finalize » Test that immediate login works if enabled, remove our code that forces the login

I actually don't see why this code is needed at all. I removed it all and left in the new tests and it all still works.

Removing this code should help with issues like #738134: Conflict with LoginToboggan submit handler.

greggles’s picture

greggles’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)
greggles’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.11 KB

Here's a re-roll for D6.

greggles’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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