diff --git a/src/SocialAuthUserManager.php b/src/SocialAuthUserManager.php index 76a2afe..6455954 100644 --- a/src/SocialAuthUserManager.php +++ b/src/SocialAuthUserManager.php @@ -170,7 +170,6 @@ class SocialAuthUserManager { return $this->authenticateNewUser($drupal_user); } - drupal_set_message($this->t('You could not be authenticated, please contact the administrator'), 'error'); $this->nullifySessionKeys(); return $this->redirect('user.login'); } @@ -292,17 +291,16 @@ class SocialAuthUserManager { $this->loggerFactory ->get($this->getPluginId()) ->error('Failed to create user. Name: @name, email: @email', array('@name' => $name, '@email' => $email)); + drupal_set_message($this->t('You could not be authenticated, please contact the administrator'), 'error'); return FALSE; } // Check if site configuration allows new users to register. - if ($this->registrationBlocked()) { + if ($this->isRegistrationDisabled()) { $this->loggerFactory ->get($this->getPluginId()) ->warning('Failed to create user. User registration is disabled. Name: @name, email: @email.', array('@name' => $name, '@email' => $email)); - drupal_set_message($this->t('User registration is disabled, please contact the administrator.'), 'error'); - return FALSE; } @@ -322,10 +320,10 @@ class SocialAuthUserManager { $violations = $new_user->validate(); if (count($violations) > 0) { $msg = $violations[0]->getMessage(); - drupal_set_message($this->t('Creation of user account failed: @message', array('@message' => $msg)), 'error'); $this->loggerFactory ->get($this->getPluginId()) ->error('Could not create new user: @message', array('@message' => $msg)); + drupal_set_message($this->t('Creation of user account failed: @message', array('@message' => $msg)), 'error'); return FALSE; } @@ -350,8 +348,10 @@ class SocialAuthUserManager { $this->loggerFactory ->get($this->getPluginId()) ->error('Could not create new user. Exception: @message', ['@message' => $ex->getMessage()]); + } + drupal_set_message($this->t('You could not be authenticated, please contact the administrator'), 'error'); return FALSE; } @@ -412,13 +412,13 @@ class SocialAuthUserManager { } /** - * Checks if user registration is blocked. + * Checks if user registration is disabled. * * @return bool - * True if registration is blocked - * False if registration is not blocked + * True if registration is disabled + * False if registration is not disabled */ - protected function registrationBlocked() { + protected function isRegistrationDisabled() { // Check if Drupal account registration settings is Administrators only // OR if it is disabled in Social Auth Settings. if ($this->configFactory->get('user.settings')->get('register') == 'admin_only' || !in_array('register', $this->configFactory->get('social_auth.settings')->get('user_allowed'), TRUE)) {