You are here

function _ga_login_force_tfa in Google Authenticator login 7

Same name and namespace in other branches
  1. 6 ga_login.module \_ga_login_force_tfa()

Check if the given account wants to be forced to use tfa.

1 call to _ga_login_force_tfa()
ga_login_user_login_validate in ./ga_login.module
Validate callback for login form.

File

./ga_login.module, line 166
Main ga_login module.

Code

function _ga_login_force_tfa($account) {
  $cant_make = !user_access('create own login code once', $account) && !user_access('create own login code', $account);

  // If the user can't create their own code and they don't already have one,
  // then we shouldn't force them to use it.
  if ($cant_make && !_ga_login_account_has_code($account)) {
    return FALSE;
  }

  // If the user belongs to any role that is required to use the code,
  // it is required, unless uid 1 and we don't require uid 1 to use a code.
  if (user_access('require code', $account) && ($account->uid != 1 || variable_get('ga_login_always_for_uid1', 0))) {
    return TRUE;
  }
  if (user_access('login without code', $account)) {
    return isset($account->data['ga_login_force_tfa']) ? $account->data['ga_login_force_tfa'] : FALSE;
  }
  return TRUE;
}