mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/oauth] Implement unlinking in OAuth
PHPBB3-11673
This commit is contained in:
parent
a2237ea8a7
commit
9cd80345ad
2 changed files with 28 additions and 0 deletions
|
@ -66,6 +66,9 @@ class ucp_auth_link
|
|||
{
|
||||
$error[] = $auth_provider->unlink_account($link_data);
|
||||
}
|
||||
|
||||
// Template data may have changed, get new data
|
||||
$provider_data = $auth_provider->get_auth_link_data();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -575,4 +575,29 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base
|
|||
'TEMPLATE_FILE' => 'ucp_auth_link_oauth.html',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function unlink_account(array $link_data)
|
||||
{
|
||||
if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service'])
|
||||
{
|
||||
return 'LOGIN_LINK_MISSING_DATA';
|
||||
}
|
||||
|
||||
// Remove the link
|
||||
$sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_account_assoc . "
|
||||
WHERE provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "'
|
||||
AND user_id = " . (int) $this->user->data['user_id'];
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
// Clear all tokens belonging to the user on this servce
|
||||
$sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_storage_table . "
|
||||
WHERE user_id = " . (int) $this->user->data['user_id'] . "
|
||||
AND provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "'";
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue