mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-05 22:14:59 +02:00
[feature/oauth] Update the OAuth service interface
PHPBB3-11673
This commit is contained in:
parent
3d55e5faa9
commit
d21ab4f629
@ -398,7 +398,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
||||
$this->service_providers[$service_name]->set_external_service_provider($service);
|
||||
|
||||
// The user has already authenticated successfully, request to authenticate again
|
||||
$unique_id = $this->service_providers[$service_name]->perform_auth_link();
|
||||
$unique_id = $this->service_providers[$service_name]->perform_token_auth();
|
||||
|
||||
// Insert into table, they will be able to log in after this
|
||||
$data = array(
|
||||
|
@ -79,4 +79,22 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_
|
||||
// Return the unique identifier returned from bitly
|
||||
return $result['data']['login'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_token_auth()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly))
|
||||
{
|
||||
// TODO: make exception class and use language constant
|
||||
throw new Exception('Invalid service provider type');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode( $this->service_provider->request('user/info'), true );
|
||||
|
||||
// Return the unique identifier returned from bitly
|
||||
return $result['data']['login'];
|
||||
}
|
||||
}
|
||||
|
@ -79,4 +79,22 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau
|
||||
// Return the unique identifier returned from bitly
|
||||
return $result['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_token_auth()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook))
|
||||
{
|
||||
// TODO: make exception class and use language constant
|
||||
throw new Exception('Invalid service provider type');
|
||||
}
|
||||
|
||||
// Send a request with it
|
||||
$result = json_decode( $this->service_provider->request('/me'), true );
|
||||
|
||||
// Return the unique identifier returned from bitly
|
||||
return $result['id'];
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function perform_auth_link()
|
||||
public function perform_token_auth()
|
||||
{
|
||||
if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google))
|
||||
{
|
||||
|
@ -57,6 +57,15 @@ interface phpbb_auth_provider_oauth_service_interface
|
||||
*/
|
||||
public function perform_auth_login();
|
||||
|
||||
/**
|
||||
* Returns the results of the authentication in json format
|
||||
* Use this function when the user already has an access token
|
||||
*
|
||||
* @return string The unique identifier returned by the service provider
|
||||
* that is used to authenticate the user with phpBB.
|
||||
*/
|
||||
public function perform_token_auth();
|
||||
|
||||
/**
|
||||
* Sets the external library service provider
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user