public function LinkedInAuthController::callback in Social Auth LinkedIn 3.x
Same name and namespace in other branches
- 8.2 src/Controller/LinkedInAuthController.php \Drupal\social_auth_linkedin\Controller\LinkedInAuthController::callback()
- 8 src/Controller/LinkedinAuthController.php \Drupal\social_auth_linkedin\Controller\LinkedinAuthController::callback()
Response for path 'user/login/linkedin/callback'.
LinkedIn returns the user here after user has authenticated.
1 string reference to 'LinkedInAuthController::callback'
File
- src/
Controller/ LinkedInAuthController.php, line 78
Class
- LinkedInAuthController
- Returns responses for Social Auth LinkedIn routes.
Namespace
Drupal\social_auth_linkedin\ControllerCode
public function callback() {
// Checks if there was an authentication error.
$redirect = $this
->checkAuthError();
if ($redirect) {
return $redirect;
}
/** @var \League\OAuth2\Client\Provider\LinkedInResourceOwner|null $profile */
$profile = $this
->processCallback();
// If authentication was successful.
if ($profile !== NULL) {
// Gets (or not) extra initial data.
$data = $this->userAuthenticator
->checkProviderIsAssociated($profile
->getId()) ? NULL : $this->providerManager
->getExtraDetails();
$name = $profile
->getFirstName() . ' ' . $profile
->getLastName();
$email = $this->providerManager
->getEmail();
// If user information could be retrieved.
return $this->userAuthenticator
->authenticateUser($name, $email, $profile
->getId(), $this->providerManager
->getAccessToken(), $profile
->getImageUrl(), $data);
}
return $this
->redirect('user.login');
}