Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/Form/BasicSetup.php b/src/Form/BasicSetup.php
- index 8ec4839..824d421 100644
- --- a/src/Form/BasicSetup.php
- +++ b/src/Form/BasicSetup.php
- @@ -72,6 +72,13 @@ class BasicSetup extends FormBase {
- $storage = $form_state->getStorage();
- // Always require a password on the first time through.
- if (empty($storage)) {
- + if($account->get('ldap_user_puid')->value ==null) {
- + $form['submit'] = [
- + '#type' => 'submit',
- + '#value' => $this->t('Click to Continue'),
- + ];
- + return $form;
- + }
- // Allow administrators to change TFA settings for another account.
- if ($account->id() == $user->id() && $account->hasPermission('administer users')) {
- $current_pass_description = $this->t('Enter your current password to
- @@ -157,6 +164,21 @@ class BasicSetup extends FormBase {
- $storage = $form_state->getStorage();
- $values = $form_state->getValues();
- $account = $form['account']['#value'];
- +
- + if($user->get('ldap_user_puid')->value ==null) {
- + if (!empty($storage['step_method'])) {
- + $method = $storage['step_method'];
- + $tfa_setup = $storage[$method];
- + // Validate plugin form.
- + if (!$tfa_setup->validateForm($form, $form_state)) {
- + foreach ($tfa_setup->getErrorMessages() as $element => $message) {
- + $form_state->setErrorByName($element, $message);
- + }
- + }
- + }
- + return;
- + }
- +
- if (isset($values['current_pass'])) {
- // Allow administrators to change TFA settings for another account.
- if ($account->id() != $user->id() && $user->hasPermission('administer users')) {
- @@ -198,6 +220,15 @@ class BasicSetup extends FormBase {
- $storage = $form_state->getStorage();
- $values = $form_state->getValues();
- + $account = User::load($this->currentUser()->id());
- +
- + if($account->get('ldap_user_puid')->value ==null) {
- + $storage['pass_confirmed'] = TRUE;
- + $form_state->setRebuild();
- + $form_state->setStorage($storage);
- + return;
- + }
- +
- // Password validation.
- if (isset($values['current_pass'])) {
- $storage['pass_confirmed'] = TRUE;
- diff --git a/src/Form/TfaLoginForm.php b/src/Form/TfaLoginForm.php
- index b21e13a..559249a 100644
- --- a/src/Form/TfaLoginForm.php
- +++ b/src/Form/TfaLoginForm.php
- @@ -150,12 +150,16 @@ class TfaLoginForm extends UserLoginForm {
- $tfa_setup_link = Url::fromRoute('tfa.overview', array(
- 'user' => $account->id(),
- ));
- +///////////////////////////////////////////////temp hack //////////////////////
- + $user_edit_link = '/user/' . $current_uid . '/edit';
- +
- $tfa_setup_link = $tfa_setup_link->toString();
- drupal_set_message($this->t('You are required to setup two-factor
- authentication <a href="@link">here.</a> You have @skipped attempts
- left after this you will be unable to login.', [
- '@skipped' => $left,
- - '@link' => $tfa_setup_link,
- + //'@link' => $tfa_setup_link,
- + '@link' => $user_edit_link,
- ]), 'error');
- $this->tfaSaveTfaData($account->id(), $this->userData, $tfa_data);
- user_login_finalize($account);
- @@ -273,3 +277,4 @@ class TfaLoginForm extends UserLoginForm {
- }
- }
- +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement