You are here

protected function SettingsTrait::isUserRoleDisabled in Social Auth 3.x

Same name and namespace in other branches
  1. 8.2 src/SettingsTrait.php \Drupal\social_auth\SettingsTrait::isUserRoleDisabled()

Checks if User with specific roles is allowed to login.

Parameters

\Drupal\user\UserInterface $drupal_user: User object to check if user has a specific role.

Return value

string|false The role that can't login. False if the user roles are not disabled.

1 call to SettingsTrait::isUserRoleDisabled()
UserAuthenticator::authenticateExistingUser in src/User/UserAuthenticator.php
Authenticates and redirects existing users in authentication process.

File

src/SettingsTrait.php, line 85

Class

SettingsTrait
Helper methods for Social Auth and Drupal settings.

Namespace

Drupal\social_auth

Code

protected function isUserRoleDisabled(UserInterface $drupal_user) {
  foreach ($this->configFactory
    ->get('social_auth.settings')
    ->get('disabled_roles') as $role) {
    if ($drupal_user
      ->hasRole($role)) {
      return $role;
    }
  }
  return FALSE;
}