mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[feature/oauth] Start linking/registering OAuth accounts during login
PHPBB3-11673
This commit is contained in:
parent
669586c134
commit
581cb37b8c
4 changed files with 30 additions and 1 deletions
|
@ -61,6 +61,7 @@ define('LOGIN_CONTINUE', 1);
|
||||||
define('LOGIN_BREAK', 2);
|
define('LOGIN_BREAK', 2);
|
||||||
define('LOGIN_SUCCESS', 3);
|
define('LOGIN_SUCCESS', 3);
|
||||||
define('LOGIN_SUCCESS_CREATE_PROFILE', 20);
|
define('LOGIN_SUCCESS_CREATE_PROFILE', 20);
|
||||||
|
define('LOGIN_SUCCESS_LINK_PROFILE', 21);
|
||||||
define('LOGIN_ERROR_USERNAME', 10);
|
define('LOGIN_ERROR_USERNAME', 10);
|
||||||
define('LOGIN_ERROR_PASSWORD', 11);
|
define('LOGIN_ERROR_PASSWORD', 11);
|
||||||
define('LOGIN_ERROR_ACTIVE', 12);
|
define('LOGIN_ERROR_ACTIVE', 12);
|
||||||
|
|
|
@ -970,6 +970,21 @@ class phpbb_auth
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the auth provider wants us to link an empty account do so and redirect
|
||||||
|
if ($login['status'] == LOGIN_SUCCESS_LINK_PROFILE)
|
||||||
|
{
|
||||||
|
// If this status exists a fourth field is in the $login array called 'redirect_data'
|
||||||
|
// This data is passed along as GET data to the next page allow the account to be linked
|
||||||
|
$url = 'ucp.php?mode=login_link';
|
||||||
|
|
||||||
|
foreach ($login['redirect_data'] as $key => $value)
|
||||||
|
{
|
||||||
|
$url .= '&' . $key . '=' . $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
// If login succeeded, we will log the user in... else we pass the login array through...
|
// If login succeeded, we will log the user in... else we pass the login array through...
|
||||||
if ($login['status'] == LOGIN_SUCCESS)
|
if ($login['status'] == LOGIN_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,6 +45,11 @@ interface phpbb_auth_provider_interface
|
||||||
* 'error_msg' => string
|
* 'error_msg' => string
|
||||||
* 'user_row' => array
|
* 'user_row' => array
|
||||||
* )
|
* )
|
||||||
|
* A fourth key of the array may be present 'redirect_data'
|
||||||
|
* This key is only used when 'status' is equal to
|
||||||
|
* LOGIN_SUCCESS_LINK_PROFILE and it's value is an
|
||||||
|
* associative array that is turned into GET variables on
|
||||||
|
* the redirect url.
|
||||||
*/
|
*/
|
||||||
public function login($username, $password);
|
public function login($username, $password);
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
||||||
if (!$row)
|
if (!$row)
|
||||||
{
|
{
|
||||||
// The user does not yet exist, ask if they wish to register the account
|
// The user does not yet exist, ask if they wish to register the account
|
||||||
throw new Exception($unique_id);
|
return array(
|
||||||
|
'status' => LOGIN_SUCCESS_LINK_PROFILE,
|
||||||
|
'error_msg' => 'LOGIN_OAUTH_ACCOUNT_NOT_LINKED',
|
||||||
|
'user_row' => array(),
|
||||||
|
'redirect_data' => array(
|
||||||
|
'auth_provider' => 'oauth',
|
||||||
|
'oauth_service' => $service_name_original,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the user's account
|
// Retrieve the user's account
|
||||||
|
|
Loading…
Add table
Reference in a new issue