You are here

trait TfaLoginTrait in Two-factor Authentication (TFA) 8

Provides methods for logging in users.

Hierarchy

3 files declare their use of TfaLoginTrait
TfaLoginController.php in src/Controller/TfaLoginController.php
TfaLoginForm.php in src/Form/TfaLoginForm.php
TfaRecoveryCodePluginTest.php in tests/src/Functional/TfaRecoveryCodePluginTest.php

File

src/TfaLoginTrait.php, line 11

Namespace

Drupal\tfa
View source
trait TfaLoginTrait {

  /**
   * Generate a hash that can uniquely identify an account's state.
   *
   * @param \Drupal\user\UserInterface $account
   *   The user account for which a hash is required.
   *
   * @return string
   *   The hash value representing the user.
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TfaLoginTrait::getLoginHash protected function Generate a hash that can uniquely identify an account's state.