1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-18 14:48:28 +01:00

[ticket/14825] Add core.auth_oauth_(login/link)_after

PHPBB3-14825
This commit is contained in:
Jakub Senko 2016-10-17 13:15:57 +02:00
parent 1dd0ceabf6
commit df0388ccc5
3 changed files with 36 additions and 1 deletions

View File

@ -62,6 +62,7 @@ services:
- @auth.provider.oauth.service_collection
- %tables.users%
- @service_container
- @dispatcher
- %core.root_path%
- %core.php_ext%
tags:

View File

@ -97,6 +97,13 @@ class oauth extends \phpbb\auth\provider\base
*/
protected $phpbb_container;
/**
* phpBB event dispatcher
*
* @var \phpbb\event\dispatcher_interface
*/
protected $dispatcher;
/**
* phpBB root path
*
@ -124,10 +131,11 @@ class oauth extends \phpbb\auth\provider\base
* @param \phpbb\di\service_collection $service_providers Contains \phpbb\auth\provider\oauth\service_interface
* @param string $users_table
* @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container
* @param \phpbb\event\dispatcher_interface $dispatcher phpBB event dispatcher
* @param string $phpbb_root_path
* @param string $php_ext
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext)
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $php_ext)
{
$this->db = $db;
$this->config = $config;
@ -139,6 +147,7 @@ class oauth extends \phpbb\auth\provider\base
$this->service_providers = $service_providers;
$this->users_table = $users_table;
$this->phpbb_container = $phpbb_container;
$this->dispatcher = $dispatcher;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
}
@ -238,6 +247,18 @@ class oauth extends \phpbb\auth\provider\base
// Update token storage to store the user_id
$storage->set_user_id($row['user_id']);
/**
* Event is triggered after user is successfuly logged in via OAuth.
*
* @event core.auth_oauth_login_after
* @var array row User row
* @since 3.1.11-RC1
*/
$vars = array(
'row',
);
extract($this->dispatcher->trigger_event('core.auth_oauth_login_after', compact($vars)));
// The user is now authenticated and can be logged in
return array(
'status' => LOGIN_SUCCESS,
@ -542,6 +563,18 @@ class oauth extends \phpbb\auth\provider\base
$sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . '
' . $this->db->sql_build_array('INSERT', $data);
$this->db->sql_query($sql);
/**
* Event is triggered after user links account.
*
* @event core.auth_oauth_link_after
* @var array data User row
* @since 3.1.11-RC1
*/
$vars = array(
'data',
);
extract($this->dispatcher->trigger_event('core.auth_oauth_link_after', compact($vars)));
}
/**

View File

@ -71,6 +71,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case
$oauth_provider_collection,
'phpbb_users',
$phpbb_container,
$phpbb_dispatcher,
$this->phpbb_root_path,
$this->php_ext
);