diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 12:55:57 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 12:56:25 -0400 |
commit | bcdeafedd7178d27dcd0fafd4b22cddeaefc80b0 (patch) | |
tree | 6d8996c779b58655deb4583fac65d2c899666c00 /phpBB | |
parent | 75206c74be23e17b2661faa0693cd308cab4d382 (diff) | |
download | forums-bcdeafedd7178d27dcd0fafd4b22cddeaefc80b0.tar forums-bcdeafedd7178d27dcd0fafd4b22cddeaefc80b0.tar.gz forums-bcdeafedd7178d27dcd0fafd4b22cddeaefc80b0.tar.bz2 forums-bcdeafedd7178d27dcd0fafd4b22cddeaefc80b0.tar.xz forums-bcdeafedd7178d27dcd0fafd4b22cddeaefc80b0.zip |
[feature/oauth] Login works on login_link now, still does not actually link
PHPBB3-11673
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/ucp/ucp_login_link.php | 97 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/ucp_login_link.html | 2 |
2 files changed, 88 insertions, 11 deletions
diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 1fb75deb61..1b9b0e45cb 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -27,7 +27,7 @@ class ucp_login_link function main($id, $mode) { - global $config, $phpbb_container, $request, $template, $user; + global $auth, $config, $phpbb_container, $request, $template, $user; $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); $auth_provider = $phpbb_container->get($auth_provider); @@ -35,25 +35,84 @@ class ucp_login_link // Initialize necessary variables $login_link_error = null; - // Ensure the person was sent here with login_link data - $data = $request->variable('login_link', array()); + // Build the data array + $data = $this->get_login_link_data_array(); + // Ensure the person was sent here with login_link data if (empty($data)) { $login_link_error = $user->lang['LOGIN_LINK_NO_DATA_PROVIDED']; - } else { - } - // Process POST and GET data - $login_error = false; - $login_username = ''; + // Have the authentication provider check that all necessary data is available + + + // Perform link action if there is no error + if (!login_link_error) + { + if ($request->is_set_post('login')) + { + $login_username = $request->variable('login_username', '', false, phpbb_request_interface::POST); + $login_password = $request->untrimmed_variable('password', '', true, phpbb_request_interface::POST); + + $result = $auth->login($login_username, $login_password); + + if ($result['status'] != LOGIN_SUCCESS) + { + // Handle all errors first + if ($result['status'] == LOGIN_BREAK) + { + trigger_error($result['error_msg']); + } + + switch ($result['status']) + { + case LOGIN_ERROR_ATTEMPTS: + + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_LOGIN); + + $template->assign_vars(array( + 'CAPTCHA_TEMPLATE' => $captcha->get_template(), + )); + + $login_error = $user->lang[$result['error_msg']]; + break; + + case LOGIN_ERROR_PASSWORD_CONVERT: + $login_error = sprintf( + $user->lang[$result['error_msg']], + ($config['email_enable']) ? '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') . '">' : '', + ($config['email_enable']) ? '</a>' : '', + ($config['board_contact']) ? '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">' : '', + ($config['board_contact']) ? '</a>' : '' + ); + break; + + // Username, password, etc... + default: + $login_error = $user->lang[$result['error_msg']]; + + // Assign admin contact to some error messages + if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') + { + $login_error = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); + } + + break; + } + } else { + // The user is now logged in, attempt to link the user to the external account + $auth_provider->link_account($data); + } + } + } // Common template elements $template->assign_vars(array( 'LOGIN_LINK_ERROR' => $login_link_error, - 'PASSWORD_CREDENTIAL' => 'password', - 'USERNAME_CREDENTIAL' => 'username', + 'PASSWORD_CREDENTIAL' => 'login_password', + 'USERNAME_CREDENTIAL' => 'login_username', )); // Registration template @@ -72,4 +131,22 @@ class ucp_login_link $this->tpl_name = 'ucp_login_link'; $this->page_title = 'UCP_LOGIN_LINK'; } + + protected function get_login_link_data_array() + { + global $request; + + $var_names = $request->variable_names(phpbb_request_interface::GET); + $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::GET); + } + } + + return $login_link_data; + } } diff --git a/phpBB/styles/prosilver/template/ucp_login_link.html b/phpBB/styles/prosilver/template/ucp_login_link.html index 5a03e08bc5..1c1fbdf528 100644 --- a/phpBB/styles/prosilver/template/ucp_login_link.html +++ b/phpBB/styles/prosilver/template/ucp_login_link.html @@ -8,7 +8,7 @@ <p>{L_LOGIN_LINK_EXPLAIN}</p> <!-- IF LOGIN_LINK_ERROR --><div class="content"> - <div class="error">{LOGIN_ERROR}</div> + <div class="error">{LOGIN_LINK_ERROR}</div> </div><!-- ENDIF --> <div class="content"> |