mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[feature/oauth] Login_link in registration
PHPBB3-11673
This commit is contained in:
parent
0cbfa8ffd4
commit
b6d93d21ba
2 changed files with 56 additions and 7 deletions
|
@ -94,9 +94,10 @@ class ucp_login_link
|
||||||
'LOGIN_LINK_ERROR' => $login_link_error,
|
'LOGIN_LINK_ERROR' => $login_link_error,
|
||||||
'PASSWORD_CREDENTIAL' => 'login_password',
|
'PASSWORD_CREDENTIAL' => 'login_password',
|
||||||
'USERNAME_CREDENTIAL' => 'login_username',
|
'USERNAME_CREDENTIAL' => 'login_username',
|
||||||
|
'S_HIDDEN_FIELDS' => $this->get_hidden_fields(),
|
||||||
|
|
||||||
// Registration elements
|
// Registration elements
|
||||||
'REGISTER_ACTION' => $this->get_register_redirect($data),
|
'REGISTER_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
|
||||||
|
|
||||||
// Login elements
|
// Login elements
|
||||||
'LOGIN_ERROR' => $login_error,
|
'LOGIN_ERROR' => $login_error,
|
||||||
|
@ -107,18 +108,18 @@ class ucp_login_link
|
||||||
$this->page_title = '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;
|
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)
|
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()
|
protected function get_login_link_data_array()
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ucp_register
|
||||||
function main($id, $mode)
|
function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
||||||
global $request;
|
global $request, $phpbb_container;
|
||||||
|
|
||||||
//
|
//
|
||||||
if ($config['require_activation'] == USER_ACTIVATION_DISABLE)
|
if ($config['require_activation'] == USER_ACTIVATION_DISABLE)
|
||||||
|
@ -78,11 +78,28 @@ class ucp_register
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$cp = new custom_profile();
|
$cp = new custom_profile();
|
||||||
|
|
||||||
$error = $cp_data = $cp_error = array();
|
$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']))
|
if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable']))
|
||||||
{
|
{
|
||||||
$add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : '';
|
$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>');
|
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
|
||||||
trigger_error($message);
|
trigger_error($message);
|
||||||
}
|
}
|
||||||
|
@ -474,4 +504,22 @@ class ucp_register
|
||||||
$this->tpl_name = 'ucp_register';
|
$this->tpl_name = 'ucp_register';
|
||||||
$this->page_title = 'UCP_REGISTRATION';
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue