1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-08 15:35:11 +02:00

[feature/oauth] Fix small bug introduced by update in OAuth library

PHPBB3-11673
This commit is contained in:
Joseph Warner 2013-09-02 16:32:24 -04:00
parent 51f06f36f1
commit 63ba064065

View File

@ -74,6 +74,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface
*/ */
public function retrieveAccessToken($service) public function retrieveAccessToken($service)
{ {
$service = $this->get_service_name_for_db($service);
if ($this->cachedToken instanceOf TokenInterface) if ($this->cachedToken instanceOf TokenInterface)
{ {
return $this->cachedToken; return $this->cachedToken;
@ -97,6 +99,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface
*/ */
public function storeAccessToken($service, TokenInterface $token) public function storeAccessToken($service, TokenInterface $token)
{ {
$service = $this->get_service_name_for_db($service);
$this->cachedToken = $token; $this->cachedToken = $token;
$data = array( $data = array(
@ -116,6 +120,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface
*/ */
public function hasAccessToken($service) public function hasAccessToken($service)
{ {
$service = $this->get_service_name_for_db($service);
if ($this->cachedToken) { if ($this->cachedToken) {
return true; return true;
} }
@ -138,6 +144,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface
*/ */
public function clearToken($service) public function clearToken($service)
{ {
$service = $this->get_service_name_for_db($service);
$this->cachedToken = null; $this->cachedToken = null;
$sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . '
@ -198,6 +206,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface
*/ */
public function has_access_token_by_session($service) public function has_access_token_by_session($service)
{ {
$service = $this->get_service_name_for_db($service);
if ($this->cachedToken) if ($this->cachedToken)
{ {
return true; return true;
@ -224,6 +234,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface
public function retrieve_access_token_by_session($service) public function retrieve_access_token_by_session($service)
{ {
$service = $this->get_service_name_for_db($service);
if ($this->cachedToken instanceOf TokenInterface) { if ($this->cachedToken instanceOf TokenInterface) {
return $this->cachedToken; return $this->cachedToken;
} }
@ -333,4 +345,22 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface
return $token; return $token;
} }
/**
* Returns the name of the service as it must be stored in the database.
*
* @param string $service The name of the OAuth service
* @return string The name of the OAuth service as it needs to be stored
* in the database.
*/
protected function get_service_name_for_db($service)
{
// Enforce the naming convention for oauth services
if (strpos($service, 'auth.provider.oauth.service.') !== 0)
{
$service = 'auth.provider.oauth.service.' . strtolower($service);
}
return $service;
}
} }