You are here

function lhfingerprintjs2_login_history_detect_device_alter in Login History 7

Implements hook_login_history_detect_device().

File

lhfingerprintjs2/lhfingerprintjs2.module, line 11
fingerprintjs2 support for the Login History module.

Code

function lhfingerprintjs2_login_history_detect_device_alter(&$detection, $edit, $account) {

  // Parse the Fingerprintjs2 data and put it in $detection.
  if (!empty($edit) && array_key_exists('lhfingerprintjs', $edit['values'])) {
    $detection['fingerprintjs2'] = $edit['values']['lhfingerprintjs'];
  }
  elseif (array_key_exists('lhfingerprintjs', $_SESSION)) {
    $detection['fingerprintjs2'] = $_SESSION['lhfingerprintjs'];
    unset($_SESSION['lhfingerprintjs']);
  }
  else {
    watchdog('lhfingerprintjs', 'Failed to detect fingerprintjs data for this user.', [], WATCHDOG_WARNING);
  }
}