Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. diff --git a/src/Form/BasicSetup.php b/src/Form/BasicSetup.php
  2. index 8ec4839..824d421 100644
  3. --- a/src/Form/BasicSetup.php
  4. +++ b/src/Form/BasicSetup.php
  5. @@ -72,6 +72,13 @@ class BasicSetup extends FormBase {
  6. $storage = $form_state->getStorage();
  7. // Always require a password on the first time through.
  8. if (empty($storage)) {
  9. + if($account->get('ldap_user_puid')->value ==null) {
  10. + $form['submit'] = [
  11. + '#type' => 'submit',
  12. + '#value' => $this->t('Click to Continue'),
  13. + ];
  14. + return $form;
  15. + }
  16. // Allow administrators to change TFA settings for another account.
  17. if ($account->id() == $user->id() && $account->hasPermission('administer users')) {
  18. $current_pass_description = $this->t('Enter your current password to
  19. @@ -157,6 +164,21 @@ class BasicSetup extends FormBase {
  20. $storage = $form_state->getStorage();
  21. $values = $form_state->getValues();
  22. $account = $form['account']['#value'];
  23. +
  24. + if($user->get('ldap_user_puid')->value ==null) {
  25. + if (!empty($storage['step_method'])) {
  26. + $method = $storage['step_method'];
  27. + $tfa_setup = $storage[$method];
  28. + // Validate plugin form.
  29. + if (!$tfa_setup->validateForm($form, $form_state)) {
  30. + foreach ($tfa_setup->getErrorMessages() as $element => $message) {
  31. + $form_state->setErrorByName($element, $message);
  32. + }
  33. + }
  34. + }
  35. + return;
  36. + }
  37. +
  38. if (isset($values['current_pass'])) {
  39. // Allow administrators to change TFA settings for another account.
  40. if ($account->id() != $user->id() && $user->hasPermission('administer users')) {
  41. @@ -198,6 +220,15 @@ class BasicSetup extends FormBase {
  42. $storage = $form_state->getStorage();
  43. $values = $form_state->getValues();
  44.  
  45. + $account = User::load($this->currentUser()->id());
  46. +
  47. + if($account->get('ldap_user_puid')->value ==null) {
  48. + $storage['pass_confirmed'] = TRUE;
  49. + $form_state->setRebuild();
  50. + $form_state->setStorage($storage);
  51. + return;
  52. + }
  53. +
  54. // Password validation.
  55. if (isset($values['current_pass'])) {
  56. $storage['pass_confirmed'] = TRUE;
  57. diff --git a/src/Form/TfaLoginForm.php b/src/Form/TfaLoginForm.php
  58. index b21e13a..559249a 100644
  59. --- a/src/Form/TfaLoginForm.php
  60. +++ b/src/Form/TfaLoginForm.php
  61. @@ -150,12 +150,16 @@ class TfaLoginForm extends UserLoginForm {
  62. $tfa_setup_link = Url::fromRoute('tfa.overview', array(
  63. 'user' => $account->id(),
  64. ));
  65. +///////////////////////////////////////////////temp hack //////////////////////
  66. + $user_edit_link = '/user/' . $current_uid . '/edit';
  67. +
  68. $tfa_setup_link = $tfa_setup_link->toString();
  69. drupal_set_message($this->t('You are required to setup two-factor
  70. authentication <a href="@link">here.</a> You have @skipped attempts
  71. left after this you will be unable to login.', [
  72. '@skipped' => $left,
  73. - '@link' => $tfa_setup_link,
  74. + //'@link' => $tfa_setup_link,
  75. + '@link' => $user_edit_link,
  76. ]), 'error');
  77. $this->tfaSaveTfaData($account->id(), $this->userData, $tfa_data);
  78. user_login_finalize($account);
  79. @@ -273,3 +277,4 @@ class TfaLoginForm extends UserLoginForm {
  80. }
  81.  
  82. }
  83. +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement