You are here

function _logintoboggan_process_validation in LoginToboggan 7

Same name and namespace in other branches
  1. 5 logintoboggan.module \_logintoboggan_process_validation()
  2. 6 logintoboggan.module \_logintoboggan_process_validation()
2 calls to _logintoboggan_process_validation()
logintoboggan_form_user_pass_reset_alter in ./logintoboggan.module
Implement hook_form_user_pass_reset_alter().
logintoboggan_validate_email in ./logintoboggan.validation.inc
@file Validation functions for LoginToboggan module.

File

./logintoboggan.module, line 1000
LoginToboggan module

Code

function _logintoboggan_process_validation($account) {

  // Test here for a valid pre-auth -- if the pre-auth is set to the auth user, we
  // handle things a bit differently.
  $validating_id = logintoboggan_validating_id();
  $pre_auth = !variable_get('user_email_verification', TRUE) && $validating_id != DRUPAL_AUTHENTICATED_RID;

  // Remove the pre-auth role from the user, unless they haven't been approved yet.
  if ($account->status) {
    if ($pre_auth) {
      db_delete('users_roles')
        ->condition('uid', $account->uid)
        ->condition('rid', $validating_id)
        ->execute();
    }
  }

  // Reload the user object freshly, since the cached value may have stale
  // roles, and to prepare for the possible user_save() below.
  $account = user_load($account->uid, TRUE);

  // Allow other modules to react to email validation by invoking the user update hook.
  // This should only be triggered if LT's custom validation is active.
  if (!variable_get('user_email_verification', TRUE)) {
    $edit = array();
    $account->logintoboggan_email_validated = TRUE;
    user_module_invoke('update', $edit, $account);
  }
}