diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 14:27:12 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 14:27:46 -0400 |
commit | 9eb4d55e8215d93256ae4ea241d40efa1d5b5854 (patch) | |
tree | eb657017bbd997f365971bb489e1204b6d2ccf8a /phpBB/phpbb/auth/provider/oauth/oauth.php | |
parent | 600c29e6ecc189aed1ba6b993c3fe79033285df1 (diff) | |
download | forums-9eb4d55e8215d93256ae4ea241d40efa1d5b5854.tar forums-9eb4d55e8215d93256ae4ea241d40efa1d5b5854.tar.gz forums-9eb4d55e8215d93256ae4ea241d40efa1d5b5854.tar.bz2 forums-9eb4d55e8215d93256ae4ea241d40efa1d5b5854.tar.xz forums-9eb4d55e8215d93256ae4ea241d40efa1d5b5854.zip |
[feature/oauth] Start work on linking an oauth account
Updates token storage to allow retrieval only by session_id
PHPBB3-11673
Diffstat (limited to 'phpBB/phpbb/auth/provider/oauth/oauth.php')
-rw-r--r-- | phpBB/phpbb/auth/provider/oauth/oauth.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index eaa111d194..0bcbcda74e 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -355,4 +355,40 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return null; } + + /** + * {@inheritdoc} + */ + public function link_account(array $link_data) + { + // We must have an oauth_service listed, check for it two ways + if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) + { + if (!$link_data['oauth_service'] && $this->request->is_set('oauth_service')) + { + $link_data['oauth_service'] = $this->request->variable('oauth_service', ''); + } + + if (!$link_data['oauth_service']) + { + return 'LOGIN_LINK_MISSING_DATA'; + } + } + + $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); + if (!array_key_exists($service_name, $this->service_providers)) + { + return 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST'; + } + + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + + // Check for an access token, they should have one + if (!$storage->has_access_token_by_sesion()) + { + return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN'; + } + + $token = $storage->retrieve_access_token_by_session(); + } } |