You are here

public function TfaContext::remainingSkips in Two-factor Authentication (TFA) 8

Remaining number of allowed logins without setting up TFA.

Return value

int|false FALSE if users are never allowed to log in without setting up TFA. The remaining number of times $this->getUser() may log in without setting up TFA.

Overrides TfaContextInterface::remainingSkips

File

src/TfaContext.php, line 156

Class

TfaContext
Provide context for the current login attempt.

Namespace

Drupal\tfa

Code

public function remainingSkips() {
  $allowed_skips = intval($this->tfaSettings
    ->get('validation_skip'));

  // Skipping TFA setup is not allowed.
  if (!$allowed_skips) {
    return FALSE;
  }
  $user_tfa_data = $this
    ->tfaGetTfaData($this
    ->getUser()
    ->id(), $this->userData);
  $validation_skipped = isset($user_tfa_data['validation_skipped']) ? $user_tfa_data['validation_skipped'] : 0;
  return max(0, $allowed_skips - $validation_skipped);
}