Restrict user registration to openID only

Events happening in the community are now at Drupal community events on www.drupal.org.
scor's picture

Is there a way to restrict user registration to openID only. I was not able to find such a module, though I looked at a few openID related modules. Optionally it could also require openID to log in such as the LDAP module does already (and disable the regular login mechanism except for uid 1).

Comments

Possible...

thepeskygeek's picture

I created this method, but it's hacky and bypasses security.

How to:

  1. Patch openid.module
  2. Disable user creations from visitors (the patch will allow user creation via OpenID)
  3. No step 3. Enjoy.

I have this live on http://in-universe.fanon.clubpenguinwiki.info.

Patch:

--- openid.module.old   2010-11-30 09:16:37.000000000 -0800
+++ openid.module       2011-02-18 20:21:00.000000000 -0800
@@ -609,7 +609,7 @@
       drupal_set_message(t('You must validate your email address for this account before logging in via OpenID.'));
     }
   }
-  elseif (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
+  else {
     // Register new user.

     // Save response for use in openid_form_user_register_form_alter().
@@ -621,6 +621,9 @@

     if (!empty($form_state['user'])) {
       module_invoke_all('openid_response', $response, $form_state['user']);
+      $newaccount = user_external_load($identity);
+      user_save($newaccount, array('status' => 1));
+      drupal_set_message(t("Your account has been created, and is now active. Please disregard the message above, you can login instantly."));
       drupal_goto();
     }

@@ -645,9 +648,6 @@
     unset($_GET['destination']);
     drupal_goto('user/register', array('query' => $destination));
   }
-  else {
-    drupal_set_message(t('Only site administrators can create new user accounts.'), 'error');
-  }
   drupal_goto();
}

Update: Updated with a friendly message.

OpenID

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: