You are here

function ga_login_delete_access in Google Authenticator login 7

Access callback for deleting codes.

1 call to ga_login_delete_access()
ga_login_form_user_profile_form_alter in ./ga_login.module
Implements hook_form_FORM_ID_alter().
1 string reference to 'ga_login_delete_access'
ga_login_menu in ./ga_login.module
Implements hook_menu().

File

./ga_login.module, line 97
Main ga_login module.

Code

function ga_login_delete_access($target_account, $account = NULL) {

  // If the account does not have a code, no need to delete it.
  if (!_ga_login_account_has_code($target_account)) {
    return FALSE;
  }
  if (is_null($account)) {
    global $user;
    $account = $user;
  }
  if ($account->uid == $target_account->uid) {

    // Only allow deleting of own code if they still can login.
    if (user_access('login without code', $account) && (user_access('delete own login code', $account) || user_access('delete others login codes', $account))) {
      return TRUE;
    }
  }
  return user_access('delete others login codes', $account);
}