Skip to content

Commit

Permalink
Abstract Social Login plugin
Browse files Browse the repository at this point in the history
Common plugin, implement default getToken() method
  • Loading branch information
Nicholas K. Dionysopoulos committed Mar 4, 2019
1 parent c44a57c commit 24d58e6
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 71 deletions.
14 changes: 0 additions & 14 deletions plugins/sociallogin/facebook/facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,6 @@ protected function getConnector()
return $this->connector;
}

/**
* Get the OAuth / OAuth2 token from the social network. Used in the onAjax* handler.
*
* @return array|bool False if we could not retrieve it. Otherwise [$token, $connector]
*
* @throws Exception
*/
protected function getToken()
{
$oauthConnector = $this->getConnector();

return [$oauthConnector->authenticate(), $oauthConnector];
}

/**
* Get the raw user profile information from the social network.
*
Expand Down
14 changes: 0 additions & 14 deletions plugins/sociallogin/github/github.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,6 @@ protected function getConnector()
return $this->connector;
}

/**
* Get the OAuth / OAuth2 token from the social network. Used in the onAjax* handler.
*
* @return array|bool False if we could not retrieve it. Otherwise [$token, $connector]
*
* @throws Exception
*/
protected function getToken()
{
$oauthConnector = $this->getConnector();

return [$oauthConnector->authenticate(), $oauthConnector];
}

/**
* Get the raw user profile information from the social network.
*
Expand Down
14 changes: 0 additions & 14 deletions plugins/sociallogin/linkedin/linkedin.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,6 @@ protected function getConnector()
return $this->connector;
}

/**
* Get the OAuth / OAuth2 token from the social network. Used in the onAjax* handler.
*
* @return array|bool False if we could not retrieve it. Otherwise [$token, $connector]
*
* @throws Exception
*/
protected function getToken()
{
$connector = $this->getConnector();

return [$connector->authenticate(), $connector];
}

/**
* Get the raw user profile information from the social network.
*
Expand Down
14 changes: 0 additions & 14 deletions plugins/sociallogin/microsoft/microsoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,6 @@ protected function getConnector()
return $this->connector;
}

/**
* Get the OAuth / OAuth2 token from the social network. Used in the onAjax* handler.
*
* @return array|bool False if we could not retrieve it. Otherwise [$token, $connector]
*
* @throws Exception
*/
protected function getToken()
{
$connector = $this->getConnector();

return [$connector->authenticate(), $connector];
}

/**
* Get the raw user profile information from the social network.
*
Expand Down
14 changes: 0 additions & 14 deletions plugins/sociallogin/twitter/twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,6 @@ protected function getLoginButtonURL()
return Uri::base() . 'index.php?option=com_ajax&group=system&plugin=sociallogin&format=raw&akaction=authenticate&encoding=redirect&slug=' . $this->integrationName . '&' . $token . '=1';
}

/**
* Get the OAuth / OAuth2 token from the social network. Used in the onAjax* handler.
*
* @return array|bool False if we could not retrieve it. Otherwise [$token, $connector]
*
* @throws Exception
*/
protected function getToken()
{
$connector = $this->getConnector();

return [$connector->authenticate(), $connector];
}

/**
* Get the raw user profile information from the social network.
*
Expand Down
9 changes: 8 additions & 1 deletion plugins/system/sociallogin/Library/Plugin/AbstractPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,15 @@ protected function getLinkButtonURL()
* Get the OAuth / OAuth2 token from the social network. Used in the onAjax* handler.
*
* @return array|bool False if we could not retrieve it. Otherwise [$token, $connector]
*
* @throws Exception
*/
protected abstract function getToken();
protected function getToken()
{
$oauthConnector = $this->getConnector();

return [$oauthConnector->authenticate(), $oauthConnector];
}

/**
* Get the raw user profile information from the social network.
Expand Down

0 comments on commit 24d58e6

Please sign in to comment.