diff options
-rw-r--r-- | phpBB/includes/ucp/ucp_login_link.php | 11 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_register.php | 52 |
2 files changed, 56 insertions, 7 deletions
diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 73991dc1a4..e60628e3c1 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -94,9 +94,10 @@ class ucp_login_link 'LOGIN_LINK_ERROR' => $login_link_error, 'PASSWORD_CREDENTIAL' => 'login_password', 'USERNAME_CREDENTIAL' => 'login_username', + 'S_HIDDEN_FIELDS' => $this->get_hidden_fields(), // Registration elements - 'REGISTER_ACTION' => $this->get_register_redirect($data), + 'REGISTER_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), // Login elements 'LOGIN_ERROR' => $login_error, @@ -107,18 +108,18 @@ class ucp_login_link $this->page_title = 'UCP_LOGIN_LINK'; } - protected function get_register_redirect($data) + protected function get_register_hidden_fields($data) { global $config, $phpbb_root_path, $phpEx, $request; - $params = 'mode=register&login_link=1&auth_provider=' . $request->variable('auth_provider', $config['auth_method']); + $fields = array(); foreach ($data as $key => $value) { - $params .= '&login_link_' . $key . '=' . $value; + $fields['login_link_' . $key] = $value; } - return append_sid("{$phpbb_root_path}ucp.$phpEx", $params); + return build_hidden_fields($s_hidden_fields); } protected function get_login_link_data_array() diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 70fbfe46fb..d52e172ec2 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -27,7 +27,7 @@ class ucp_register function main($id, $mode) { global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; - global $request; + global $request, $phpbb_container; // if ($config['require_activation'] == USER_ACTIVATION_DISABLE) @@ -78,11 +78,28 @@ class ucp_register } } - $cp = new custom_profile(); $error = $cp_data = $cp_error = array(); + // Handle login_link data added to $_hidden_fields + $login_link_data = $this->get_login_link_data_array(); + + if ($login_link_data !== array()) + { + // Confirm that we have all necessary data + $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); + $auth_provider = $phpbb_container->get($auth_provider); + + $result = $auth_provider->login_link_has_necessary_data($data); + if ($result !== null) + { + $error[] = $user->lang[$result]; + } + + $s_hidden_fields = array_merge($s_hidden_fields, $login_link_data); + } + if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable'])) { $add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : ''; @@ -398,6 +415,19 @@ class ucp_register } } + // Perform account linking if necessary + if ($login_link_data !== array()) + { + $login_link_data['user_id'] = $user_id; + + $result = $auth_provider->link_account($login_link_data); + + if ($result) + { + $message = $message . '<br /><br />' . $user->lang[$result]; + } + } + $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>'); trigger_error($message); } @@ -474,4 +504,22 @@ class ucp_register $this->tpl_name = 'ucp_register'; $this->page_title = 'UCP_REGISTRATION'; } + + protected function get_login_link_data_array() + { + global $request; + + $var_names = $request->variable_names(phpbb_request_interface::POST); + $login_link_data = array(); + + foreach ($var_names as $var_name) + { + if (strpos($var_name, 'login_link_') === 0) + { + $login_link_data[$var_name] = $request->variable($var_name, '', false, phpbb_request_interface::POST); + } + } + + return $login_link_data; + } } |