I installed and enabled this module ... added some email addresses using the "add" function, enabled the various roles that registered user could choose from...then tried to create a new account using an email address that was NOT on the pre-approved list. I could create an account (site was set to public registration with no approval required) -- and get a verification email. I clicked the one-time link in the verification email and tried to set a password, but was not sure if that worked. I then used the recover password feature and the one-time link logged me in to the site and gave me access to the content reserved for authenticated users. I thought this module would keep people from being able to register if not pre-approved? Any suggestions would be helpful.

Comments

johnhanley’s picture

I thought this module would keep people from being able to register if not pre-approved?

No, the module doesn't prevent users from registering. It's only intended to assign custom roles to users that match a "pre-approved" email address or domain.

Your idea is a good one though and might make a nice feature request, but I don't personally have the bandwidth to facilitate such a request unless it's paid work.

adamwhite’s picture

We implemented this with a small custom module (in 7.x, not 6.x). It works something like this:

function MYMODULE_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  $form['#validate'][] = 'MYMODULE_validate_register_form';
}

function MYMODULE_validate_register_form(&$form, &$form_state) {

  $pattern = db_select('register_preapproved', 'rp')
    ->fields('rp')
    ->condition(db_or()
      ->condition('mail', $form_state['values']['mail'])
      ->condition('mail', strstr($form_state['values']['mail'], '@'))
    )
    ->execute()
    ->fetchAssoc();

  if (empty($pattern)) {
    $message = variable_get('MYMODULE_not_preapproved_message', t('Your email address has not been pre-approved for use on %site_name.'));
    form_set_error('mail', t($message, array('%site_name' => variable_get('site_name', 'Drupal'))));
  }
}

I'm not sure if that's worth a patch or not, maybe as an optional submodule to this one?

johnhanley’s picture

Hey Adam,

That looks like a simple elegant solution to OP's request--thanks! Ideally it should be a configurable option (which would be easy to implement).

The 7.x version of this module is sorely in need of some attention (i.e. there's a couple of other patches in the issue queue.) I will ping the maintainer (KeyboardCowboy) of the 7.x branch and see if he's got bandwidth to work on this otherwise I will carve out some time to do it myself.

John

johnhanley’s picture

Version: 6.x-1.2 » 7.x-1.x-dev
Category: Support request » Feature request
Status: Active » Needs review

  • 2a966a4 committed on 7.x-1.x
    Issue #1989344 Cannot access Admin interface
    
    Issue #2292571 Make...
johnhanley’s picture

Status: Needs review » Closed (fixed)

Added to in 7.x-1.0 release. Thank you!