public function UserAuthenticator::authenticateNewUser in Social Auth 8.2
Same name and namespace in other branches
- 3.x src/User/UserAuthenticator.php \Drupal\social_auth\User\UserAuthenticator::authenticateNewUser()
Authenticates and redirects new users in authentication process.
Parameters
\Drupal\user\UserInterface|null $drupal_user: User object to login.
1 call to UserAuthenticator::authenticateNewUser()
- UserAuthenticator::authenticateUser in src/
User/ UserAuthenticator.php - Creates and/or authenticates an user.
File
- src/
User/ UserAuthenticator.php, line 302
Class
- UserAuthenticator
- Manages Drupal authentication tasks for Social Auth.
Namespace
Drupal\social_auth\UserCode
public function authenticateNewUser(UserInterface $drupal_user = NULL) {
// If it's a valid Drupal user.
if ($drupal_user) {
// If the account needs admin approval.
if ($this
->isApprovalRequired()) {
$this->messenger
->addWarning($this
->t("Your account was created, but it needs administrator's approval."));
$this
->nullifySessionKeys();
$this->response = $this
->getLoginFormRedirection();
return;
}
// 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) {
$this->response = $redirect;
return;
}
$this->response = $this
->getPostLoginRedirection();
return;
}
}
if (!$this
->isRegistrationDisabled()) {
$this->messenger
->addError($this
->t('You could not be authenticated. Contact site administrator.'));
}
$this
->nullifySessionKeys();
$this->response = $this
->getLoginFormRedirection();
}