You are here

protected function TfaLoginTrait::getLoginHash in Two-factor Authentication (TFA) 8

Generate a hash that can uniquely identify an account's state.

Parameters

\Drupal\user\UserInterface $account: The user account for which a hash is required.

Return value

string The hash value representing the user.

2 calls to TfaLoginTrait::getLoginHash()
TfaLoginController::access in src/Controller/TfaLoginController.php
Denies access unless user matches hash value.
TfaLoginForm::loginWithTfa in src/Form/TfaLoginForm.php
Handle login when TFA is set up for the user.

File

src/TfaLoginTrait.php, line 22

Class

TfaLoginTrait
Provides methods for logging in users.

Namespace

Drupal\tfa

Code

protected function getLoginHash(UserInterface $account) {

  // Using account login will mean this hash will become invalid once user has
  // authenticated via TFA.
  $data = implode(':', [
    $account
      ->getAccountName(),
    $account
      ->getPassword(),
    $account
      ->getLastLoginTime(),
  ]);
  return Crypt::hashBase64($data);
}