You are here

public function SocialAuthUserManager::authenticateNewUser in Social Auth 8

Authenticates and redirects new users in authentication process.

Parameters

\Drupal\user\UserInterface $drupal_user: User object to login.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect response.

1 call to SocialAuthUserManager::authenticateNewUser()
SocialAuthUserManager::authenticateUser in src/SocialAuthUserManager.php
Creates and/or authenticates an user.

File

src/SocialAuthUserManager.php, line 222

Class

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

Namespace

Drupal\social_auth

Code

public function authenticateNewUser(UserInterface $drupal_user) {

  // If the account needs admin approval.
  if ($this
    ->isApprovalRequired()) {
    drupal_set_message($this
      ->t("Your account was created, but it needs administrator's approval"), 'warning');
    $this
      ->nullifySessionKeys();
    return $this
      ->redirect('user.login');
  }

  // If the new user could be logged in.
  if ($this
    ->loginUser($drupal_user)) {

    // User form redirection or false if option is not enabled.
    $redirect = $this
      ->redirectToUserForm($drupal_user);
    if ($redirect) {
      return $redirect;
    }
    else {
      return $this
        ->getLoginPostPath();
    }
  }
}