From fa14bf0ba656bf6e1efc0111e98c7d80ec0263f9 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Mon, 4 Mar 2019 18:34:17 +0200 Subject: [PATCH] Abstract Social Login plugin Common plugin, shaping up the code --- .../sociallogin/Library/Plugin/AbstractPlugin.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/system/sociallogin/Library/Plugin/AbstractPlugin.php b/plugins/system/sociallogin/Library/Plugin/AbstractPlugin.php index 9785940..5cc7951 100644 --- a/plugins/system/sociallogin/Library/Plugin/AbstractPlugin.php +++ b/plugins/system/sociallogin/Library/Plugin/AbstractPlugin.php @@ -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'); @@ -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); @@ -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);