mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 04:04:13 +02:00
Minor updates to Tfa class
This commit is contained in:
@@ -207,7 +207,7 @@ class Tfa extends WireData implements Module, ConfigurableModule {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function init() {
|
public function init() {
|
||||||
if($this->className() != 'Tfa') $this->initHooks();
|
$this->initHooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1192,9 +1192,13 @@ class Tfa extends WireData implements Module, ConfigurableModule {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function initHooks() {
|
protected function initHooks() {
|
||||||
$this->addHookBefore('InputfieldForm::render', $this, 'hookInputfieldFormRender');
|
if($this->className() === 'Tfa') {
|
||||||
$this->addHookBefore('InputfieldForm::processInput', $this, 'hookBeforeInputfieldFormProcess');
|
$this->addHookBefore('InputfieldForm::render', $this, 'hookInputfieldFormRender');
|
||||||
$this->addHookAfter('InputfieldForm::processInput', $this, 'hookAfterInputfieldFormProcess');
|
} else {
|
||||||
|
$this->addHookBefore('InputfieldForm::render', $this, 'hookInputfieldFormRender');
|
||||||
|
$this->addHookBefore('InputfieldForm::processInput', $this, 'hookBeforeInputfieldFormProcess');
|
||||||
|
$this->addHookAfter('InputfieldForm::processInput', $this, 'hookAfterInputfieldFormProcess');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1319,7 +1323,7 @@ class Tfa extends WireData implements Module, ConfigurableModule {
|
|||||||
$inputfields = $event->object;
|
$inputfields = $event->object;
|
||||||
|
|
||||||
// if form does not have a “tfa_type” field, then exit
|
// if form does not have a “tfa_type” field, then exit
|
||||||
$inputfield = $inputfields->getChildByName($this->userFieldName);
|
$inputfield = $inputfields->getChildByName($this->userFieldName);
|
||||||
if(!$inputfield) return;
|
if(!$inputfield) return;
|
||||||
|
|
||||||
/** @var InputfieldRadios $inputfield */
|
/** @var InputfieldRadios $inputfield */
|
||||||
@@ -1877,14 +1881,11 @@ class RememberTfa extends Wire {
|
|||||||
public function ___getFingerprintArray() {
|
public function ___getFingerprintArray() {
|
||||||
|
|
||||||
$agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'noagent';
|
$agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'noagent';
|
||||||
|
|
||||||
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
$fwip = '';
|
||||||
$fwip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $fwip .= $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
} else if(isset($_SERVER['HTTP_CLIENT_IP'])) {
|
if(isset($_SERVER['HTTP_CLIENT_IP'])) $fwip .= ' ' . $_SERVER['HTTP_CLIENT_IP'];
|
||||||
$fwip = $_SERVER['HTTP_CLIENT_IP'];
|
if(empty($fwip)) $fwip = 'nofwip';
|
||||||
} else {
|
|
||||||
$fwip = 'nofwip';
|
|
||||||
}
|
|
||||||
|
|
||||||
$fingerprints = array(
|
$fingerprints = array(
|
||||||
'agent' => $agent,
|
'agent' => $agent,
|
||||||
|
Reference in New Issue
Block a user