mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/oauth] Start implementing link/unlink actions
PHPBB3-11673
This commit is contained in:
parent
836d3ba22e
commit
67b1ec5bb8
3 changed files with 26 additions and 6 deletions
|
@ -48,7 +48,20 @@ class ucp_auth_link
|
|||
|
||||
if (!sizeof($error))
|
||||
{
|
||||
// Any post data could be necessary for auth (un)linking
|
||||
$link_data = $request->get_super_global(phpbb_request_interface::POST);
|
||||
|
||||
// The current user_id is also necessary
|
||||
$link_data['user_id'] = $user->data['user_id'];
|
||||
|
||||
if ($request->variable('link', false, false, phpbb_request_interface::POST))
|
||||
{
|
||||
$error[] = $auth_provider->link_account($link_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error[] = $auth_provider->unlink_account($link_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -405,10 +405,18 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
|||
return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN';
|
||||
}
|
||||
|
||||
// Prepare the query string
|
||||
if ($this->request->variable('mode', 'login_link'))
|
||||
{
|
||||
$query = 'mode=login_link';
|
||||
} else {
|
||||
$query = 'i=ucp_auth_link&mode=auth_link';
|
||||
}
|
||||
$query .= '&login_link_oauth_service=' . strtolower($link_data['oauth_service']);
|
||||
|
||||
// Prepare for an authentication request
|
||||
$service_credentials = $this->service_providers[$service_name]->get_service_credentials();
|
||||
$scopes = $this->service_providers[$service_name]->get_auth_scope();
|
||||
$query = 'mode=login_link&login_link_oauth_service=' . strtolower($link_data['oauth_service']);
|
||||
$service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query);
|
||||
$this->service_providers[$service_name]->set_external_service_provider($service);
|
||||
|
||||
|
@ -462,7 +470,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
|||
|
||||
$oauth_user_ids = array();
|
||||
|
||||
if ($rows !== false && !empty($rows))
|
||||
if ($rows !== false && sizeof($rows))
|
||||
{
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
|
@ -478,14 +486,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
|||
if ($credentials['key'] && $credentials['secret'])
|
||||
{
|
||||
$actual_name = str_replace('auth.provider.oauth.service.', '', $service_name);
|
||||
$redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name;
|
||||
|
||||
$block_vars[$service_name] = array(
|
||||
'HIDDEN_FIELDS' => array(
|
||||
'link' => (!isset($oauth_user_ids[$actual_name])),
|
||||
'oauth_service' => $actual_name,
|
||||
),
|
||||
|
||||
'REDIRECT_URL' => redirect($redirect_url, true),
|
||||
'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)],
|
||||
'UNIQUE_ID' => (isset($oauth_user_ids[$actual_name])) ? $oauth_user_ids[$actual_name] : null,
|
||||
);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</dl>
|
||||
<dl>
|
||||
<dt> </dt>
|
||||
<dd><input type="submit" name="unlink" tabindex="6" value="{L_UNLINK}" class="button1" /></dd>
|
||||
<dd><input type="submit" name="submit" tabindex="6" value="{L_UNLINK}" class="button1" /></dd>
|
||||
</dl>
|
||||
<!-- ELSE -->
|
||||
<dl>
|
||||
|
@ -18,7 +18,7 @@
|
|||
</dl>
|
||||
<dl>
|
||||
<dt> </dt>
|
||||
<dd><input type="submit" name="link" tabindex="6" value="{L_LINK}" class="button1" /></dd>
|
||||
<dd><input type="submit" name="submit" tabindex="6" value="{L_LINK}" class="button1" /></dd>
|
||||
</dl>
|
||||
<!-- ENDIF-->
|
||||
</fieldset>
|
||||
|
|
Loading…
Add table
Reference in a new issue