Skip to content

Commit

Permalink
Pass additional user data with all PBS fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdubz committed Feb 15, 2019
1 parent 86f84a3 commit ccf9b53
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Controller/PbsAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\social_auth_pbs\Controller;

use Drupal\Component\Serialization\Json;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\social_api\Plugin\NetworkManager;
use Drupal\social_auth\Controller\OAuth2ControllerBase;
Expand All @@ -16,6 +17,13 @@
*/
class PbsAuthController extends OAuth2ControllerBase {

/**
* The JSON Serialize servicer.
*
* @var \Drupal\Component\Serialization\Json
*/
protected $jsonSerializer;

/**
* PbsAuthController constructor.
*
Expand All @@ -31,13 +39,16 @@ class PbsAuthController extends OAuth2ControllerBase {
* Used to access GET parameters.
* @param \Drupal\social_auth\SocialAuthDataHandler $data_handler
* SocialAuthDataHandler object.
* @param \Drupal\Component\Serialization\Json $json_serializer
* Used to serialize additional data.
*/
public function __construct(MessengerInterface $messenger,
NetworkManager $network_manager,
UserAuthenticator $user_authenticator,
PbsAuthManager $pbs_auth_manager,
RequestStack $request,
SocialAuthDataHandler $data_handler) {
SocialAuthDataHandler $data_handler,
Json $json_serializer) {

parent::__construct(
'Social Auth PBS',
Expand All @@ -49,6 +60,7 @@ public function __construct(MessengerInterface $messenger,
$request,
$data_handler
);
$this->jsonSerializer = $json_serializer;
}

/**
Expand All @@ -61,7 +73,8 @@ public static function create(ContainerInterface $container) {
$container->get('social_auth.user_authenticator'),
$container->get('social_auth_pbs.manager'),
$container->get('request_stack'),
$container->get('social_auth.data_handler')
$container->get('social_auth.data_handler'),
$container->get('serialization.json')
);
}

Expand All @@ -84,7 +97,8 @@ public function callback() {
$profile->getEmail(),
$profile->getId(),
$this->providerManager->getAccessToken(),
$profile->getThumbnailUrl()
$profile->getThumbnailUrl(),
$this->jsonSerializer->encode($profile->toArray())
);
}

Expand Down

0 comments on commit ccf9b53

Please sign in to comment.