diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-09-02 16:32:24 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-09-02 16:32:40 -0400 |
commit | 63ba06406575b5c7882ef26ee3b5469ca16afec5 (patch) | |
tree | fd7f448cf4f4a2351e6a56c5a7b389e80decedd4 | |
parent | 51f06f36f1f90429b48cab473f0eaf2b57b1b811 (diff) | |
download | forums-63ba06406575b5c7882ef26ee3b5469ca16afec5.tar forums-63ba06406575b5c7882ef26ee3b5469ca16afec5.tar.gz forums-63ba06406575b5c7882ef26ee3b5469ca16afec5.tar.bz2 forums-63ba06406575b5c7882ef26ee3b5469ca16afec5.tar.xz forums-63ba06406575b5c7882ef26ee3b5469ca16afec5.zip |
[feature/oauth] Fix small bug introduced by update in OAuth library
PHPBB3-11673
-rw-r--r-- | phpBB/phpbb/auth/provider/oauth/token_storage.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 15f491c9dc..f9ba28ee69 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -74,6 +74,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function retrieveAccessToken($service) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken instanceOf TokenInterface) { return $this->cachedToken; @@ -97,6 +99,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function storeAccessToken($service, TokenInterface $token) { + $service = $this->get_service_name_for_db($service); + $this->cachedToken = $token; $data = array( @@ -116,6 +120,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function hasAccessToken($service) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken) { return true; } @@ -138,6 +144,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function clearToken($service) { + $service = $this->get_service_name_for_db($service); + $this->cachedToken = null; $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) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken) { return true; @@ -224,6 +234,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface public function retrieve_access_token_by_session($service) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken instanceOf TokenInterface) { return $this->cachedToken; } @@ -333,4 +345,22 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface 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; + } } |