mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 14:48:53 +00:00
[ticket/13740] Login admin when install finished
PHPBB3-13740
This commit is contained in:
parent
dd31020fb3
commit
fbd5929606
7 changed files with 101 additions and 7 deletions
|
@ -165,6 +165,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set cookies
|
||||||
|
function setCookies(cookies) {
|
||||||
|
var cookie;
|
||||||
|
|
||||||
|
for (var i = 0; i < cookies.length; i++) {
|
||||||
|
// Set cookie name and value
|
||||||
|
cookie = encodeURIComponent(cookies[i].name) + '=' + encodeURIComponent(cookies[i].value);
|
||||||
|
// Set path
|
||||||
|
cookie += '; path=/';
|
||||||
|
document.cookie = cookie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse messages from the response object
|
* Parse messages from the response object
|
||||||
*
|
*
|
||||||
|
@ -199,6 +212,10 @@
|
||||||
if (responseObject.hasOwnProperty('nav')) {
|
if (responseObject.hasOwnProperty('nav')) {
|
||||||
updateNavbarStatus(responseObject.nav);
|
updateNavbarStatus(responseObject.nav);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (responseObject.hasOwnProperty('cookies')) {
|
||||||
|
setCookies(responseObject.cookies);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,6 +338,7 @@
|
||||||
$contentWrapper.append($spinner);
|
$contentWrapper.append($spinner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Submits a form
|
||||||
function submitForm($form, $submitBtn) {
|
function submitForm($form, $submitBtn) {
|
||||||
$form.css('display', 'none');
|
$form.css('display', 'none');
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace phpbb\install\helper;
|
namespace phpbb\install\helper;
|
||||||
|
|
||||||
|
use phpbb\cache\driver\dummy;
|
||||||
use phpbb\install\exception\cannot_build_container_exception;
|
use phpbb\install\exception\cannot_build_container_exception;
|
||||||
|
|
||||||
class container_factory
|
class container_factory
|
||||||
|
@ -152,6 +153,10 @@ class container_factory
|
||||||
// this container
|
// this container
|
||||||
$this->container->register('request')->setSynthetic(true);
|
$this->container->register('request')->setSynthetic(true);
|
||||||
$this->container->set('request', $this->request);
|
$this->container->set('request', $this->request);
|
||||||
|
|
||||||
|
// Replace cache service, as config gets cached, and we don't want that
|
||||||
|
$this->container->register('cache.driver')->setSynthetic(true);
|
||||||
|
$this->container->set('cache.driver', new dummy());
|
||||||
$this->container->compile();
|
$this->container->compile();
|
||||||
|
|
||||||
// Restore super globals to previous state
|
// Restore super globals to previous state
|
||||||
|
|
|
@ -43,6 +43,11 @@ class ajax_iohandler extends iohandler_base
|
||||||
*/
|
*/
|
||||||
protected $nav_data;
|
protected $nav_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $cookies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -55,6 +60,7 @@ class ajax_iohandler extends iohandler_base
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->form = '';
|
$this->form = '';
|
||||||
$this->nav_data = array();
|
$this->nav_data = array();
|
||||||
|
$this->cookies = array();
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
@ -214,6 +220,12 @@ class ajax_iohandler extends iohandler_base
|
||||||
$this->request_client_refresh = false;
|
$this->request_client_refresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($this->cookies))
|
||||||
|
{
|
||||||
|
$json_array['cookies'] = $this->cookies;
|
||||||
|
$this->cookies = array();
|
||||||
|
}
|
||||||
|
|
||||||
return $json_array;
|
return $json_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,6 +264,17 @@ class ajax_iohandler extends iohandler_base
|
||||||
$this->send_response();
|
$this->send_response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function set_cookie($cookie_name, $cookie_value)
|
||||||
|
{
|
||||||
|
$this->cookies[] = array(
|
||||||
|
'name' => $cookie_name,
|
||||||
|
'value' => $cookie_value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback function for language replacing
|
* Callback function for language replacing
|
||||||
*
|
*
|
||||||
|
|
|
@ -255,4 +255,11 @@ class cli_iohandler extends iohandler_base
|
||||||
public function set_finished_stage_menu($menu_path)
|
public function set_finished_stage_menu($menu_path)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function set_cookie($cookie_name, $cookie_value)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,4 +163,12 @@ interface iohandler_interface
|
||||||
* @param string $message_lang_key Language key for the message
|
* @param string $message_lang_key Language key for the message
|
||||||
*/
|
*/
|
||||||
public function finish_progress($message_lang_key);
|
public function finish_progress($message_lang_key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends and sets cookies
|
||||||
|
*
|
||||||
|
* @param string $cookie_name Name of the cookie to set
|
||||||
|
* @param string $cookie_value Value of the cookie to set
|
||||||
|
*/
|
||||||
|
public function set_cookie($cookie_name, $cookie_value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\install\module\install_finish\task;
|
namespace phpbb\install\module\install_finish\task;
|
||||||
|
use phpbb\config\db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs installation and sends an email to the admin
|
* Logs installation and sends an email to the admin
|
||||||
|
@ -73,11 +74,17 @@ class notify_user extends \phpbb\install\task_base
|
||||||
$this->iohandler = $iohandler;
|
$this->iohandler = $iohandler;
|
||||||
|
|
||||||
$this->auth = $container->get('auth');
|
$this->auth = $container->get('auth');
|
||||||
$this->config = $container->get('config');
|
|
||||||
$this->log = $container->get('log');
|
$this->log = $container->get('log');
|
||||||
$this->user = $container->get('user');
|
$this->user = $container->get('user');
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $php_ext;
|
$this->php_ext = $php_ext;
|
||||||
|
|
||||||
|
// We need to reload config for cases when it doesn't have all values
|
||||||
|
$this->config = new db(
|
||||||
|
$container->get('dbal.conn'),
|
||||||
|
$container->get('cache.driver'),
|
||||||
|
$container->get_parameter('tables.config')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,11 +92,8 @@ class notify_user extends \phpbb\install\task_base
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
// @todo Login user after installation has been finished
|
$this->user->session_begin();
|
||||||
//$this->user->setup('common');
|
$this->user->setup('common');
|
||||||
|
|
||||||
//$this->user->session_begin();
|
|
||||||
//$this->auth->login($this->install_config->get('admin_name'), $this->install_config->get('admin_pass1'), false, true, true);
|
|
||||||
|
|
||||||
if ($this->config['email_enable'])
|
if ($this->config['email_enable'])
|
||||||
{
|
{
|
||||||
|
@ -106,8 +110,31 @@ class notify_user extends \phpbb\install\task_base
|
||||||
$messenger->send(NOTIFY_EMAIL);
|
$messenger->send(NOTIFY_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_INSTALL_INSTALLED', false, array($this->config['version']));
|
// Login admin
|
||||||
|
// Ugly but works
|
||||||
|
$this->auth->login(
|
||||||
|
$this->install_config->get('admin_name'),
|
||||||
|
$this->install_config->get('admin_passwd'),
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->iohandler->set_cookie($this->config['cookie_name'] . '_sid', $this->user->session_id);
|
||||||
|
$this->iohandler->set_cookie($this->config['cookie_name'] . '_u', $this->user->cookie_data['u']);
|
||||||
|
$this->iohandler->set_cookie($this->config['cookie_name'] . '_k', $this->user->cookie_data['k']);
|
||||||
|
|
||||||
|
// Create log
|
||||||
|
$this->log->add(
|
||||||
|
'admin',
|
||||||
|
$this->user->data['user_id'],
|
||||||
|
$this->user->ip,
|
||||||
|
'LOG_INSTALL_INSTALLED',
|
||||||
|
false,
|
||||||
|
array($this->config['version'])
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove install_lock
|
||||||
@unlink($this->phpbb_root_path . 'cache/install_lock');
|
@unlink($this->phpbb_root_path . 'cache/install_lock');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1076,6 +1076,12 @@ class session
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// If headers are already set, we just return
|
||||||
|
if (headers_sent())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$name_data = rawurlencode($config['cookie_name'] . '_' . $name) . '=' . rawurlencode($cookiedata);
|
$name_data = rawurlencode($config['cookie_name'] . '_' . $name) . '=' . rawurlencode($cookiedata);
|
||||||
$expire = gmdate('D, d-M-Y H:i:s \\G\\M\\T', $cookietime);
|
$expire = gmdate('D, d-M-Y H:i:s \\G\\M\\T', $cookietime);
|
||||||
$domain = (!$config['cookie_domain'] || $config['cookie_domain'] == '127.0.0.1' || strpos($config['cookie_domain'], '.') === false) ? '' : '; domain=' . $config['cookie_domain'];
|
$domain = (!$config['cookie_domain'] || $config['cookie_domain'] == '127.0.0.1' || strpos($config['cookie_domain'], '.') === false) ? '' : '; domain=' . $config['cookie_domain'];
|
||||||
|
|
Loading…
Add table
Reference in a new issue