aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorJoseph Warner <hardolaf@hardolaf.com>2013-07-24 13:46:33 -0400
committerJoseph Warner <hardolaf@hardolaf.com>2013-07-24 13:46:33 -0400
commit581cb37b8c7ae4f1902cfd6114a34ce1510139a8 (patch)
treeaae7b4d463c7c64ad0e2ac0528b41961abce3b8e /phpBB/phpbb
parent669586c134641b29a95faa43090df124b59d4e14 (diff)
downloadforums-581cb37b8c7ae4f1902cfd6114a34ce1510139a8.tar
forums-581cb37b8c7ae4f1902cfd6114a34ce1510139a8.tar.gz
forums-581cb37b8c7ae4f1902cfd6114a34ce1510139a8.tar.bz2
forums-581cb37b8c7ae4f1902cfd6114a34ce1510139a8.tar.xz
forums-581cb37b8c7ae4f1902cfd6114a34ce1510139a8.zip
[feature/oauth] Start linking/registering OAuth accounts during login
PHPBB3-11673
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/auth/auth.php15
-rw-r--r--phpBB/phpbb/auth/provider/interface.php5
-rw-r--r--phpBB/phpbb/auth/provider/oauth/oauth.php10
3 files changed, 29 insertions, 1 deletions
diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php
index 279959974d..400f5fef6d 100644
--- a/phpBB/phpbb/auth/auth.php
+++ b/phpBB/phpbb/auth/auth.php
@@ -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['status'] == LOGIN_SUCCESS)
{
diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php
index f4344c1dc7..9cee63abeb 100644
--- a/phpBB/phpbb/auth/provider/interface.php
+++ b/phpBB/phpbb/auth/provider/interface.php
@@ -45,6 +45,11 @@ interface phpbb_auth_provider_interface
* 'error_msg' => string
* '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);
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php
index 90ce1f8f5a..5fc940fade 100644
--- a/phpBB/phpbb/auth/provider/oauth/oauth.php
+++ b/phpBB/phpbb/auth/provider/oauth/oauth.php
@@ -172,7 +172,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
if (!$row)
{
// 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