diff --git a/src/Form/BasicOverview.php b/src/Form/BasicOverview.php index 2a5d4cb..b737d68 100644 --- a/src/Form/BasicOverview.php +++ b/src/Form/BasicOverview.php @@ -144,6 +144,28 @@ class BasicOverview extends FormBase { ]; } + if ( $configuration['enabled'] ) { + $output['validation_skip_status'] = [ + '#type' => 'markup', + '#markup' => '

' . $this->t( 'No. of times validation skipped' ) . ': ' + . $user_tfa['validation_skipped'] . ' of ' + . $configuration['validation_skip'] . '

' + ]; + } + + if ($this->currentUser()->hasPermission('administer users')) { + $output['actions'] = ['#type' => 'actions']; + $output['actions']['reset_skip_attempts'] = [ + '#type' => 'submit', + '#value' => $this->t('Reset skip validation attempts'), + '#submit' => ['::resetSkipValidationAttempts'], + ]; + $output['account'] = [ + '#type' => 'value', + '#value' => $user, + ]; + } + return $output; } @@ -184,4 +206,17 @@ class BasicOverview extends FormBase { public function submitForm(array &$form, FormStateInterface $form_state) { } + /** + * + */ + public function resetSkipValidationAttempts($form, $form_state) { + $account = $form_state->getValue('account'); + $tfa_data = $this->tfaGetTfaData($account->id(), $this->userData); + $tfa_data['validation_skipped'] = 0; + $this->tfaSaveTfaData($account->id(), $this->userData, $tfa_data); + drupal_set_message($this->t('Skipped validation attempts set to zero for user @name', [ + '@name' => $account->getDisplayName(), + ])); + } + }