You are here

public function SocialAuthUserManager::loginUser in Social Auth 8

Logs the user in.

Parameters

\Drupal\user\Entity\User $drupal_user: User object.

Return value

bool True if login was successful False if the login was blocked

2 calls to SocialAuthUserManager::loginUser()
SocialAuthUserManager::authenticateExistingUser in src/SocialAuthUserManager.php
Authenticates and redirects existing users in authentication process.
SocialAuthUserManager::authenticateNewUser in src/SocialAuthUserManager.php
Authenticates and redirects new users in authentication process.

File

src/SocialAuthUserManager.php, line 353

Class

SocialAuthUserManager
Contains all logic that is related to Drupal user management.

Namespace

Drupal\social_auth

Code

public function loginUser(User $drupal_user) {

  // Check that the account is active and log the user in.
  if ($drupal_user
    ->isActive()) {
    $this
      ->userLoginFinalize($drupal_user);

    // Dipatches SocialAuthEvents::USER_LOGIN event.
    $event = new SocialAuthUserEvent($drupal_user, $this
      ->getPluginId());
    $this->eventDispatcher
      ->dispatch(SocialAuthEvents::USER_LOGIN, $event);
    return TRUE;
  }
  $this->loggerFactory
    ->get($this
    ->getPluginId())
    ->warning('Login for user @user prevented. Account is blocked.', array(
    '@user' => $drupal_user
      ->getAccountName(),
  ));
  return FALSE;
}