Skip to content

Commit

Permalink
Issue #82: Make the subscriber aware of the new setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed Jun 6, 2019
1 parent b801ee2 commit 803ead4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Event/EuLoginEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\user\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\oe_authentication\CasProcessor;
Expand Down Expand Up @@ -106,12 +107,16 @@ public function processUserProperties(CasPreRegisterEvent $event): void {
$attributes = $event->getCasPropertyBag()->getAttributes();
$event->setPropertyValues(CasProcessor::convertCasAttributesToFieldValues($attributes));

// If the site is configured to need administrator approval,
// change the status of the account to blocked.
// If the site is configured to require administrator approval on user
// registration and OE Authentication is configured to register new users as
// disabled users, change the status of the account to blocked.
$user_settings = $this->configFactory->get('user.settings');
if ($user_settings->get('register') === USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) {
$event->setPropertyValue('status', 0);
$this->messenger->addStatus($this->t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.'));
if ($user_settings->get('register') === UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) {
$oe_authentication_settings = $this->configFactory->get('oe_authentication.settings');
if ($oe_authentication_settings->get('block_on_site_admin_approval')) {
$event->setPropertyValue('status', 0);
$this->messenger->addStatus($this->t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.'));
}
}
}

Expand Down

0 comments on commit 803ead4

Please sign in to comment.