Commit 54b648a1 authored by lazysoundsystem's avatar lazysoundsystem Committed by Peter Droogmans
Browse files

Issue #3267858 by lazysoundsystem: Allow option to prevent creation of new...

Issue #3267858 by lazysoundsystem: Allow option to prevent creation of new users without social_auth accounts
parent 71beee75
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -140,6 +140,13 @@ class HidAuthSettingsForm extends SocialAuthSettingsForm {
      '#default_value' => $config->get('disable_user_field'),
    ];

    $form['hid_settings']['advanced']['disable_user_create'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Disable user create form'),
      '#description' => $this->t('Ensure users have a social_auth login by disallowing creation of users directly in the ѕite.'),
      '#default_value' => $config->get('disable_user_create'),
    ];

    $form['hid_settings']['advanced']['maintenance_access'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Allow HID logins during maintenance mode'),
@@ -174,6 +181,7 @@ class HidAuthSettingsForm extends SocialAuthSettingsForm {
      ->set('disable_password_fields', $values['disable_password_fields'])
      ->set('disable_email_field', $values['disable_email_field'])
      ->set('disable_user_field', $values['disable_user_field'])
      ->set('disable_user_create', $values['disable_user_create'])
      ->set('maintenance_access', $values['maintenance_access'])
      ->save();

+7 −0
Original line number Diff line number Diff line
@@ -64,6 +64,13 @@ class RouteSubscriber extends RouteSubscriberBase {
        $route->setRequirement('_access', 'FALSE');
      }
    }

    // Deny access to user_create form.
    if ($this->config->get('disable_user_create')) {
      if ($route = $collection->get('user.admin_create')) {
        $route->setRequirement('_access', 'FALSE');
      }
    }
  }

}