You are here

function logintoboggan_revalidate_access in LoginToboggan 7

Same name and namespace in other branches
  1. 6 logintoboggan.module \logintoboggan_revalidate_access()

Access check for user revalidation.

1 string reference to 'logintoboggan_revalidate_access'
logintoboggan_menu in ./logintoboggan.module
Implement hook_menu()

File

./logintoboggan.module, line 730
LoginToboggan module

Code

function logintoboggan_revalidate_access($account) {
  if (!($GLOBALS['user']->uid && ($GLOBALS['user']->uid == $account->uid || user_access('administer users')))) {
    return FALSE;
  }

  //limit max number of revalidation requests that a user can trigger
  if (!user_access('administer users')) {
    flood_register_event('logintoboggan_revalidate-ip');
    flood_register_event('logintoboggan_revalidate-uid', 3600, $account->uid);
    $threshold = variable_get('logintoboggan_revalidate_threshold', 4);
    if (!flood_is_allowed('logintoboggan_revalidate-ip', $threshold) || !flood_is_allowed('logintoboggan_revalidate-uid', $threshold, 3600, $account->uid)) {
      drupal_set_message(t('You have already requested a validation email within the last hour.'), 'warning');
      return FALSE;
    }
  }
  return TRUE;
}