Skip to content

Commit

Permalink
Abstract Social Login plugin
Browse files Browse the repository at this point in the history
Common plugin, shaping up the code
  • Loading branch information
Nicholas K. Dionysopoulos committed Mar 4, 2019
1 parent 24d58e6 commit fa14bf0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions plugins/system/sociallogin/Library/Plugin/AbstractPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ public function onSocialLoginUnlink($slug, $user = null)
Integrations::removeUserProfileData($user->id, 'sociallogin.' . $this->integrationName);
}

/**
* Handles the social network login callback, gets social network user information and performs the Social Login
* flow (including logging in non-linked users or creating a new user from the social media profile)
*
* @throws Exception
*/
protected function onSocialLoginAjax()
{
Joomla::log($this->integrationName, 'Begin handing of authentication callback');
Expand Down Expand Up @@ -464,9 +470,9 @@ protected function onSocialLoginAjax()
{
Joomla::log($this->integrationName, 'Receive token from the social network', Log::INFO);

$tokenResponse = $this->getToken();
list($token, $connector) = $this->getToken();

if ($tokenResponse === false)
if ($token === false)
{
Joomla::log($this->integrationName, 'Received token from social network is invalid or the user has declined application authorization', Log::ERROR);

Expand All @@ -485,8 +491,6 @@ protected function onSocialLoginAjax()
throw new LoginError($errorMessage);
}

list($token, $connector) = $tokenResponse;

// Get information about the user from the social network
Joomla::log($this->integrationName, 'Retrieving social network profile information', Log::INFO);

Expand Down

0 comments on commit fa14bf0

Please sign in to comment.