* [ADD] Error page for common errors during initialization.

* [FIX] Minor bugfixes
This commit is contained in:
nuxsmin
2018-03-19 23:36:30 +01:00
parent 85de6fd507
commit e4167f06fc
23 changed files with 167 additions and 462 deletions

View File

@@ -36,7 +36,6 @@ use SP\Core\Context\ContextInterface;
use SP\Core\Context\SessionContext;
use SP\Core\Events\EventDispatcher;
use SP\Core\Exceptions\FileNotFoundException;
use SP\Core\Language;
use SP\Core\UI\Theme;
use SP\DataModel\ProfileData;
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
@@ -91,10 +90,6 @@ abstract class ControllerBase
* @var EventDispatcher
*/
protected $eventDispatcher;
/**
* @var bool
*/
protected $loggedIn = false;
/**
* @var ConfigData
*/
@@ -163,8 +158,6 @@ abstract class ControllerBase
$this->setViewVars();
}
$this->view->assign('language', substr(Language::$globalLang, 0, 2));
if (method_exists($this, 'initialize')) {
$this->initialize();
}

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -24,11 +24,12 @@
namespace SP\Modules\Web\Controllers;
use DI\Container;
use Klein\Klein;
use SP\Bootstrap;
use SP\Core\Exceptions\FileNotFoundException;
use SP\Core\Exceptions\SPException;
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
use SP\Mvc\View\Template;
use SP\Services\Install\Installer;
use SP\Util\Util;
/**
* Class ErrorController
@@ -45,36 +46,83 @@ class ErrorController
* @var Klein
*/
protected $router;
/**
* @var LayoutHelper
*/
protected $layoutHelper;
/**
* ErrorController constructor.
* @param Template $view
* @param Klein $router
*
* @param Container $container
* @param string $actionName
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
*/
public function __construct(Template $view, Klein $router)
public function __construct(Container $container, $actionName)
{
$this->view = $view;
$this->router = $router;
$this->view = $container->get(Template::class);
$this->view->setBase('error');
$this->router = $container->get(Klein::class);
$this->layoutHelper = $container->get(LayoutHelper::class);
$this->layoutHelper->getPublicLayout('error');
}
/**
* @todo
* indexAction
*/
public function indexAction()
{
$this->view->assign('startTime', microtime());
$this->layoutHelper->getPublicLayout('error');
$this->view();
}
$this->view->assign('appInfo', Util::getAppInfo());
$this->view->assign('appVersion', Installer::VERSION_TEXT);
$this->view->assign('logoIcon', Bootstrap::$WEBURI . '/public/images/logo_icon.png');
$this->view->assign('logoNoText', Bootstrap::$WEBURI . '/public/images/logo_icon.svg');
$this->view->assign('logo', Bootstrap::$WEBURI . '/public/images/logo_full_bg.png');
$this->view->assign('logonobg', Bootstrap::$WEBURI . '/public/images/logo_full_nobg.png');
$this->view->assign('lang', 'en');
$this->view->assign('error', 'Error!');
/**
* Mostrar los datos de la plantilla
*/
protected function view()
{
try {
echo $this->view->render();
} catch (FileNotFoundException $e) {
processException($e);
$this->router->response()->header('Content-Type', 'text/html; charset=UTF-8');
$this->router->response()->header('Cache-Control', 'public, no-cache, max-age=0, must-revalidate');
$this->router->response()->header('Pragma', 'public; max-age=0');
echo __($e->getMessage());
}
die();
}
/**
* databaseErrorAction
*/
public function maintenanceErrorAction()
{
$this->layoutHelper->getPublicLayout('error-maintenance');
$this->view->append('errors', [
'type' => SPException::WARNING,
'description' => __('Aplicación en mantenimiento'),
'hint' => __('En breve estará operativa')
]);
$this->view();
}
/**
* databaseErrorAction
*/
public function databaseErrorAction()
{
$this->layoutHelper->getPublicLayout('error-database');
$this->view->append('errors', [
'type' => SPException::CRITICAL,
'description' => __('Error en la verificación de la base de datos'),
'hint' => __('Consulte con el administrador')
]);
$this->view();
}
}

View File

@@ -112,7 +112,7 @@ class LayoutHelper extends HelperBase
$this->loggedIn = $this->context->isLoggedIn();
$this->view->assign('loggedIn', $this->loggedIn);
$this->view->assign('lang', $this->loggedIn ? Language::$userLang : Language::$globalLang);
$this->view->assign('lang', $this->loggedIn ? Language::$userLang : substr(Language::$globalLang, 0, 2));
$this->view->assign('loadApp', $this->context->getAuthCompleted());
@@ -340,23 +340,6 @@ class LayoutHelper extends HelperBase
return $this;
}
/**
* Sets a full layout page
*
* @param string $page Page/view name
* @return LayoutHelper
*/
public function getErrorLayout($page = '')
{
$this->view->addTemplate('error', '_layouts');
$this->view->assign('useFixedHeader');
$this->setPage($page);
$this->initBody();
return $this;
}
/**
* Sets a custom layout page
*

View File

@@ -119,7 +119,7 @@ class InstallController extends ControllerBase
try {
$this->dic->get(Installer::class)->run($installData);
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS_STICKY, __u('Instalación finalizada'));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Instalación finalizada'));
} catch (\Exception $e) {
processException($e);

View File

@@ -33,7 +33,6 @@ use SP\Core\Context\SessionContext;
use SP\Core\Crypt\CryptSessionHandler;
use SP\Core\Crypt\SecureKeyCookie;
use SP\Core\Crypt\Session as CryptSession;
use SP\Core\Exceptions\InitializationException;
use SP\Core\Language;
use SP\Core\ModuleBase;
use SP\Core\UI\Theme;
@@ -57,7 +56,7 @@ class Init extends ModuleBase
* List of controllers that don't need to perform fully initialization
* like: install/database checks, session/event handlers initialization
*/
const PARTIAL_INIT = ['resource', 'install', 'bootstrap', 'status', 'upgrade'];
const PARTIAL_INIT = ['resource', 'install', 'bootstrap', 'status', 'upgrade', 'error'];
/**
* @var SessionContext
@@ -92,7 +91,6 @@ class Init extends ModuleBase
* Initialize Web App
*
* @param string $controller
* @throws InitializationException
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
* @throws \SP\Core\Exceptions\SPException
@@ -144,19 +142,17 @@ class Init extends ModuleBase
}
// Checks if maintenance mode is turned on
$this->checkMaintenanceMode($this->context);
if ($this->checkMaintenanceMode($this->context)) {
$this->router->response()
->redirect('index.php?r=error/maintenanceError')
->send();
}
try {
// Checks if the database is set up
DBUtil::checkDatabaseExist($this->container->get(Database::class)->getDbHandler(), $this->configData->getDbName());
} catch (\Exception $e) {
if ($e->getCode() === 1049) {
$this->router->response()
->redirect('index.php?r=install/index')
->send();
}
throw new InitializationException($e->getMessage());
// Checks if the database is set up
if (!DBUtil::checkDatabaseExist($this->container->get(Database::class)->getDbHandler(), $this->configData->getDbName())) {
$this->router->response()
->redirect('index.php?r=error/databaseError')
->send();
}
// Checks if upgrade is needed

View File

@@ -1,47 +0,0 @@
<?php /** @var \SP\Mvc\View\Template $this */ ?>
<!DOCTYPE html>
<html lang="<?php echo $language; ?>">
<head>
<title><?php echo $appInfo['appname'], ' :: ', $appInfo['appdesc']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="<?php echo $logoIcon; ?>">
<?php foreach ($cssLinks as $cssLink): ?>
<link rel="stylesheet" href="<?php echo $cssLink; ?>"/>
<?php endforeach; ?>
</head>
<body>
<div id="wrap">
<noscript>
<div id="nojs"><?php echo __('Javascript es necesario para el correcto funcionamiento'); ?></div>
</noscript>
<div id="wrap-loading">
<div id="loading" class="mdl-spinner mdl-spinner--single-color mdl-js-spinner"></div>
<div id="taskStatus"></div>
</div>
<div id="container" class="<?php echo $page; ?>" data-page="<?php echo $page; ?>">
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--no-desktop-drawer-button">
<header class="mdl-layout__header mdl-color--indigo-400">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-icon">
<img class="logo btn-menu" src="<?php echo $logonobg; ?>"
alt="logo"/>
</span>
</div>
</header>
<main class="mdl-layout__content">
<div id="content">
<?php include $this->includePartial('error'); ?>
</div>
</main>
</div>
</div> <!-- Close container -->
<?php include $this->includePartial('footer'); ?>
</div> <!-- Close wrap -->
</body> <!-- Close BODY...almost done..go..go..go -->
</html> <!-- Close HTML...ufff too much work!! :)) -->
<!-- Insert coin . . . -->

View File

@@ -1,6 +1,6 @@
<?php /** @var \SP\Mvc\View\Template $this */ ?>
<!DOCTYPE html>
<html lang="<?php echo $language; ?>">
<html lang="<?php echo $lang; ?>">
<head>
<title><?php echo $appInfo['appname'], ' :: ', $appInfo['appdesc']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

View File

@@ -1,3 +0,0 @@
<main class="mdl-layout__content">
<div id="content"></div>
</main>

View File

@@ -1,17 +0,0 @@
<?php foreach ($jsLinks as $jsLink): ?>
<script type="text/javascript" src="<?php echo $jsLink; ?>"></script>
<?php endforeach; ?>
<script type="text/javascript">
$(document).ready(function (e) {
"use strict";
sysPassApp.log.info("ready");
sysPassApp.sk.set("<?php echo $sk; ?>");
});
</script>
</body> <!-- Close BODY...almost done..go..go..go -->
</html> <!-- Close HTML...ufff too much work!! :)) -->
<!-- Insert coin . . . -->

View File

@@ -1,69 +0,0 @@
<?php /** @var \SP\Core\UI\ThemeIcons $icons */
/** @var \SP\Html\Assets\IconInterface $userType */
if ($useLayout === true): ?>
</div> <!-- Close mdl-layout -->
<?php endif; ?>
</div> <!-- Close container -->
<footer>
<div id="footer-left" class="footer-parts">
<?php if ($loadApp === true && isset($userName)): ?>
<div id="session">
<span id="user-info">
<?php if ($userType !== null): ?>
<i id="user-type-footer" class="material-icons"><?php echo $userType->getIcon(); ?></i>
<span for="user-type-footer"
class="mdl-tooltip mdl-tooltip--top"><?php echo $userType->getTitle(); ?></span>
<?php else: ?>
<i class="material-icons">face</i>
<?php endif; ?>
<span id="user-name-footer"><?php echo $userName; ?></span>
<span for="user-name-footer"
class="mdl-tooltip mdl-tooltip--top"><?php printf('%s : %s', __('Grupo'), $userGroup); ?></span>
</span>
</div>
<?php endif; ?>
</div>
<div id="footer-right" class="footer-parts">
<div id="status">
<?php if ($httpsEnabled): ?>
<span id="secure-info" class="status-info">
<i class="material-icons mdl-color-text--teal-500">https</i>
</span>
<span for="secure-info"
class="mdl-tooltip mdl-tooltip--top"><?php echo 'HTTPS'; ?></span>
<?php else: ?>
<span id="secure-info" class="status-info">
<i class="material-icons mdl-color-text--red-900">http</i>
</span>
<span for="secure-info"
class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large"><?php echo __('Indica si la conexión utiliza HTTPS.') . '<br><br>' . __('Las claves de formularios enviados se encriptan mediante PKI, el resto de datos no.'); ?></span>
<?php endif; ?>
<?php if (DEBUG): ?>
<i class="material-icons mdl-color-text--red-900" title="Debug ON">bug_report</i>
<?php endif; ?>
<?php if ($isDemoMode): ?>
<span class="status-info">
<i class="material-icons mdl-color-text--teal-500" title="<?php echo __('Demo'); ?>">play_circle_outline</i>
</span>
<?php endif; ?>
<div id="updates"></div>
</div>
<div id="project">
<a id="app-info" href="<?php echo $appInfo['appwebsite']; ?>" target="_blank">
<?php echo $appInfo['appname'], ' ', $appVersion; ?>
</a>
<span for="app-info"
class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large"><?php echo __('Ayuda :: FAQ :: Changelog'); ?></span>
&nbsp;::&nbsp;
<a id="app-project" href="<?php echo $appInfo['appblog']; ?>" target="_blank">cygnux.org</a>
<span for="app-project"
class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large"><?php echo __('Un proyecto de cygnux.org'); ?></span>
</div>
<!-- Close Project -->
</div>
</footer> <!-- Close footer -->
</div> <!-- Close wrap -->

View File

@@ -1,164 +0,0 @@
<header class="mdl-layout__header mdl-color--indigo-400">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-icon">
<img class="logo btn-menu" src="<?php echo $logonobg; ?>"
alt="logo"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::ACCOUNT_SEARCH; ?>"
data-view="search"
data-historyReset="1"/>
</span>
<!-- <span class="mdl-layout-title">--><?php //echo '#', $appInfo['appname']; ?><!--</span>-->
<?php if ($loggedIn): ?>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation -->
<nav class="mdl-navigation mdl-layout--large-screen-only">
<?php /** @var \SP\Html\DataGrid\DataGridAction $action */
foreach ($actions as $action): ?>
<a id="btn-<?php echo $action->getId(); ?>" class="btn-menu mdl-navigation__link"
<?php foreach ($action->getData() as $dataName => $dataValue): ?>
<?php echo 'data-', $dataName, '="', $dataValue, '"'; ?>
<?php endforeach; ?>>
<i class="material-icons"><?php echo $action->getIcon()->getIcon(); ?></i>
</a>
<span for="btn-<?php echo $action->getId(); ?>"
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $action->getTitle(); ?></span>
<?php endforeach; ?>
<?php if ($userNotices > 0): ?>
<a id="notices-user" class="btn-menu mdl-navigation__link"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::NOTICE; ?>"
data-historyreset="1"
data-view="notices">
<i class="material-icons mdl-badge mdl-badge--overlap" data-badge="<?php echo $userNotices; ?>">notifications</i>
</a>
<span for="notices-user"
class="mdl-tooltip mdl-tooltip--bottom"><?php printf(__('Hay %d notificaciones pendientes'), $userNotices); ?></span>
<?php else: ?>
<a id="notices-user" class="btn-menu mdl-navigation__link"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::NOTICE; ?>"
data-historyreset="1"
data-view="notices">
<i class="material-icons mdl-badge mdl-badge--overlap" data-badge="0">notifications</i>
</a>
<span for="notices-user"
class="mdl-tooltip mdl-tooltip--bottom"><?php echo __('No hay no hay notificaciones pendientes'); ?></span>
<?php endif; ?>
<!-- User's menu -->
<!-- Right aligned menu below button -->
<button id="users-menu-lower-right"
class="mdl-button mdl-js-button mdl-button--icon">
<i class="material-icons">more_vert</i>
</button>
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
for="users-menu-lower-right">
<?php if ($showPassIcon): ?>
<li id="btnUserPass" class="btn-action mdl-menu__item"
data-onclick="appMgmt/show"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::USER_EDIT_PASS; ?>"
data-item-id="<?php echo $userId; ?>"
data-sk="<?php echo $sk; ?>">
<i class="material-icons">security</i>
<?php echo __('Cambiar Clave de Usuario'); ?>
</li>
<?php endif; ?>
<li id="btnPrefs" class="mdl-menu__item"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::PREFERENCE; ?>">
<i class="material-icons">account_circle</i>
<?php echo __('Preferencias de usuario'); ?>
</li>
<li id="btnLogout" class="mdl-menu__item">
<i class="material-icons">exit_to_app</i>
<?php echo __('Salir'); ?>
</li>
</ul>
</nav>
<?php endif; ?>
</div>
</header>
<?php if ($loggedIn === true): ?>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title"><?php echo $appInfo['appname']; ?></span>
<nav class="mdl-navigation">
<?php /** @var \SP\Html\DataGrid\DataGridAction $action */
foreach ($actions as $action): ?>
<a class="btn-menu mdl-navigation__link"
title="<?php echo $action->getTitle(); ?>"
data-action-id="<?php echo $action->getId(); ?>"
<?php foreach ($action->getData() as $dataName => $dataValue): ?>
<?php echo 'data-', $dataName, '="', $dataValue, '"'; ?>
<?php endforeach; ?>>
<i class="material-icons"><?php echo $action->getIcon()->getIcon(); ?></i>
<?php echo $action->getTitle(); ?>
</a>
<?php endforeach; ?>
<?php if ($userNotices > 0): ?>
<a id="notices-user" class="btn-menu mdl-navigation__link"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::NOTICE; ?>"
data-historyreset="1"
data-view="notices">
<i class="material-icons mdl-badge mdl-badge--overlap" data-badge="<?php echo $userNotices; ?>">notifications</i>
<?php echo __('Notificaciones'); ?>
</a>
<?php else: ?>
<a id="notices-user" class="btn-menu mdl-navigation__link"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::NOTICE; ?>"
data-historyreset="1"
data-view="notices">
<i class="material-icons mdl-badge mdl-badge--overlap" data-badge="0">notifications</i>
<?php echo __('Notificaciones'); ?>
</a>
<?php endif; ?>
<?php if ($showPassIcon): ?>
<a class="btn-action mdl-navigation__link"
title="<?php echo __('Cambiar Clave de Usuario'); ?>"
data-onclick="appMgmt/show"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::USER_EDIT_PASS; ?>"
data-item-id="<?php echo $userId; ?>"
data-sk="<?php echo $sk; ?>">
<i class="btn-action material-icons">security</i>
<?php echo __('Cambiar Clave de Usuario'); ?>
</a>
<?php endif; ?>
<a class="btn-menu mdl-navigation__link"
title="<?php echo __('Preferencias de usuario'); ?>"
data-action-id="<?php echo \SP\Core\Acl\ActionsInterface::PREFERENCE; ?>">
<i class="btn-action material-icons">account_circle</i>
<span id="user-name"><?php echo $userName; ?></span>
<span for="user-name"
class="mdl-tooltip mdl-tooltip--top"><?php printf('%s : %s', __('Grupo'), $userGroup); ?></span>
<?php /** @var \SP\Html\Assets\IconInterface $userType */
if ($userType !== null): ?>
<i id="user-type" class="material-icons"><?php echo $userType->getIcon(); ?></i>
<span for="user-type"
class="mdl-tooltip mdl-tooltip--top"><?php echo $userType->getTitle(); ?></span>
<?php endif; ?>
</a>
<a class="btn-action mdl-navigation__link" title="<?php echo __('Salir'); ?>"
data-onclick="main/logout">
<i class="material-icons">exit_to_app</i>
<?php echo __('Salir'); ?>
</a>
<a class="mdl-navigation__link" href="#">
<?php if ($httpsEnabled): ?>
<i class="material-icons mdl-color-text--teal-500">lock</i>
<?php else: ?>
<i class="material-icons mdl-color-text--red-900">lock_open</i>
<?php endif; ?>
<?php if ($isDemoMode): ?>
<span class="status-info"><?php echo __('Demo'); ?></span>
<?php endif; ?>
<?php echo $appInfo['appname'], ' ', $appVersion; ?>
</a>
</nav>
</div>
<?php endif; ?>

View File

@@ -1,6 +0,0 @@
<header class="mdl-layout__header mdl-color--indigo-400">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-icon"><img class="logo" src="<?php echo $logonobg; ?>" alt="logo"/></span>
</div>
</header>

View File

@@ -1,13 +0,0 @@
<body>
<div id="wrap">
<noscript>
<div id="nojs"><?php echo __('Javascript es necesario para el correcto funcionamiento'); ?></div>
</noscript>
<div id="wrap-loading">
<div id="loading" class="mdl-spinner mdl-spinner--single-color mdl-js-spinner"></div>
<div id="taskStatus"></div>
</div>
<div id="container" class="<?php echo $page; ?>" data-page="<?php echo $page; ?>">
<?php if ($useLayout === true): ?>
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--no-desktop-drawer-button">
<?php endif; ?>

View File

@@ -1,40 +1,19 @@
<?php
/**
* sysPass
*
* @author nuxsmin
* @link http://syspass.org
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @var $icons \SP\Core\UI\ThemeIcons
* @var \SP\Mvc\View\Template $this
* @var \SP\Core\UI\ThemeIcons $icons
* @var \SP\Mvc\View\Template $this
*/
?>
<div id="actions" align="center">
<?php include $this->includePartial('error-list'); ?>
<div class="buttons">
<button id="btnBack" class="btn-back mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
<i class="material-icons"
title="<?php echo __('Volver'); ?>"><?php echo $icons->getIconBack()->getIcon(); ?></i>
<?php echo __('Volver'); ?>
</button>
</div>
<?php if (!isset($skipBackButton)): ?>
<div class="buttons">
<button id="btnBack" class="btn-back mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
<i class="material-icons"
title="<?php echo __('Volver'); ?>"><?php echo $icons->getIconBack()->getIcon(); ?></i>
<?php echo __('Volver'); ?>
</button>
</div>
<?php endif; ?>
</div>

View File

@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="<?php echo $lang; ?>">
<head>
<title><?php echo $appInfo['appname'], ' :: ', $appInfo['appdesc']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="<?php echo $logoIcon; ?>">
<?php foreach ($cssLinks as $cssLink): ?>
<link rel="stylesheet" href="<?php echo $cssLink; ?>"/>
<?php endforeach; ?>
</head>

View File

@@ -0,0 +1,22 @@
<?php
/**
* @var \SP\Core\UI\ThemeIcons $icons
* @var \SP\Mvc\View\Template $this
*/
?>
<div id="actions" align="center">
<?php include $this->includePartial('error-list'); ?>
<div class="buttons">
<button id="btnBack" class="btn-back mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
<i class="material-icons"
title="<?php echo __('Volver'); ?>"><?php echo $icons->getIconBack()->getIcon(); ?></i>
<?php echo __('Volver'); ?>
</button>
<a class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="index.php?r=install">
<?php echo __('Instalar'); ?>
<i class="material-icons"
title="<?php echo __('Instalar'); ?>"><?php echo $icons->getIconPlay()->getIcon(); ?></i>
</a>
</div>
</div>

View File

@@ -0,0 +1,17 @@
<?php
/**
* @var \SP\Core\UI\ThemeIcons $icons
* @var \SP\Mvc\View\Template $this
*/
?>
<div id="actions" align="center">
<?php include $this->includePartial('error-list'); ?>
<div class="buttons">
<button id="btnBack" class="btn-back mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
<i class="material-icons"
title="<?php echo __('Volver'); ?>"><?php echo $icons->getIconBack()->getIcon(); ?></i>
<?php echo __('Volver'); ?>
</button>
</div>
</div>

View File

@@ -30,8 +30,6 @@ use SP\Bootstrap;
use SP\Config\Config;
use SP\Core\Context\ContextInterface;
use SP\Core\Events\EventDispatcher;
use SP\Core\Exceptions\InitializationException;
use SP\Http\Request;
use SP\Providers\Log\LogHandler;
use SP\Providers\Mail\MailHandler;
use SP\Providers\Notification\NotificationHandler;
@@ -89,28 +87,22 @@ abstract class ModuleBase
* Devuelve un error 503 y un reintento de 120s al cliente.
*
* @param ContextInterface $context
* @param bool $check sólo comprobar si está activado el modo
* @throws InitializationException
* @return bool
*/
public function checkMaintenanceMode(ContextInterface $context, $check = false)
public function checkMaintenanceMode(ContextInterface $context)
{
if ($this->configData->isMaintenance()) {
Bootstrap::$LOCK = Util::getAppLock();
if ($check === true
|| Checks::isAjax($this->router)
|| Request::analyzeInt('nodbupgrade') === 1
|| (Bootstrap::$LOCK !== false && Bootstrap::$LOCK->userId > 0 && $context->isLoggedIn() && Bootstrap::$LOCK->userId === $context->getUserData()->getId())
) {
return;
}
throw new InitializationException(
__u('Aplicación en mantenimiento'),
InitializationException::INFO,
__u('En breve estará operativa')
);
return (Checks::isAjax($this->router)
|| (Bootstrap::$LOCK !== false
&& Bootstrap::$LOCK->userId > 0
&& $context->isLoggedIn()
&& Bootstrap::$LOCK->userId === $context->getUserData()->getId())
) === false;
}
return false;
}
/**

View File

@@ -188,8 +188,6 @@ class Installer extends Service
$this->configService->create(new \SP\DataModel\ConfigData('version', $version));
$this->configData->setInstalled(true);
$this->configData->setDatabaseVersion($version);
$this->configData->setConfigVersion($version);
$this->config->saveConfig($this->configData, false);
}
@@ -229,7 +227,11 @@ class Installer extends Service
{
// Generate a random salt that is used to salt the local user passwords
$this->configData->setPasswordSalt(Util::generateRandomBytes(30));
// Sets version and remove upgrade key
$this->configData->setConfigVersion(Util::getVersionStringNormalized());
$this->configData->setDatabaseVersion(Util::getVersionStringNormalized());
$this->configData->setUpgradeKey(null);
// Set DB connection info
$this->configData->setDbHost($this->installData->getDbHost());

View File

@@ -195,11 +195,11 @@ class MySQL implements DatabaseSetupInterface
$query = /** @lang SQL */
'GRANT ALL PRIVILEGES ON `' . $this->installData->getDbName() . '`.*
TO `' . $this->installData->getDbUser() . '`@`' . $this->installData->getDbAuthHost() . '`';
TO `' . $this->configData->getDbUser() . '`@`' . $this->installData->getDbAuthHost() . '`';
$queryDns = /** @lang SQL */
'GRANT ALL PRIVILEGES ON `' . $this->installData->getDbName() . '`.*
TO `' . $this->installData->getDbUser() . '`@`' . $this->installData->getDbAuthHostDns() . '`';
TO `' . $this->configData->getDbUser() . '`@`' . $this->installData->getDbAuthHostDns() . '`';
try {
$dbc->exec($query);
@@ -257,8 +257,8 @@ class MySQL implements DatabaseSetupInterface
}
} else {
$dbc->exec('DROP DATABASE IF EXISTS `' . $this->installData->getDbName() . '`');
$dbc->exec('DROP USER `' . $this->installData->getDbUser() . '`@`' . $this->installData->getDbAuthHost() . '`');
$dbc->exec('DROP USER `' . $this->installData->getDbUser() . '`@`' . $this->installData->getDbAuthHostDns() . '`');
$dbc->exec('DROP USER `' . $this->configData->getDbUser() . '`@`' . $this->installData->getDbAuthHost() . '`');
$dbc->exec('DROP USER `' . $this->configData->getDbUser() . '`@`' . $this->installData->getDbAuthHostDns() . '`');
// $this->DB->exec('DROP USER `' . $this->InstallData->getDbUser() . '`@`%`');
}

View File

@@ -30,7 +30,6 @@ use SP\Core\Crypt\Crypt;
use SP\Core\Crypt\Hash;
use SP\Core\Crypt\Session as CryptSession;
use SP\Core\Exceptions\SPException;
use SP\Core\Upgrade\Crypt as CryptUpgrade;
use SP\Core\Upgrade\User as UpgradeUser;
use SP\DataModel\UserLoginData;
use SP\Repositories\User\UserRepository;
@@ -117,6 +116,7 @@ class UserPassService extends Service
}
if ($userLoginResponse->getIsMigrate() === 1) {
// FIXME
return UpgradeUser::upgradeMasterKey($userLoginData, $this) ? new UserPassResponse(self::MPASS_OK) : new UserPassResponse(self::MPASS_WRONG);
}
@@ -186,9 +186,7 @@ class UserPassService extends Service
$this->configService->save('masterPwd', $configHashMPass);
}
if (Hash::checkHashKey($userMPass, $configHashMPass)
|| CryptUpgrade::migrateHash($userMPass)
) {
if (Hash::checkHashKey($userMPass, $configHashMPass)) {
$response = $this->createMasterPass($userMPass, $userLoginData->getLoginUser(), $userLoginData->getLoginPass());
$this->userRepository->updateMasterPassById($userData->getId(), $response->getCryptMasterPass(), $response->getCryptSecuredKey());

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -24,7 +24,6 @@
namespace SP\Storage;
use RuntimeException;
use SP\Core\Exceptions\SPException;
/**
@@ -126,17 +125,23 @@ class DBUtil
public static function checkDatabaseExist(DBStorageInterface $DBStorage, $dbName)
{
try {
$tables = array_map(function ($value) {
return '\'' . $value . '\'';
}, self::$tables);
$query = /** @lang SQL */
'SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = \'' . $dbName . '\'
AND `table_name` IN (\'Client\', \'Category\', \'Account\', \'User\', \'Config\', \'EventLog\')';
AND `table_name` IN (' . implode(',', $tables) . ')';
return (int)$DBStorage->getConnection()->query($query)->fetchColumn() === 6;
$numTables = $DBStorage->getConnection()->query($query)->fetchColumn();
return (int)$numTables === count(self::$tables);
} catch (\Exception $e) {
processException($e);
throw new RuntimeException(__u('Error en la verificación de la base de datos'));
}
return false;
}
}