Merge remote-tracking branch 'origin/crypt' into crypt

Conflicts:
	inc/SP/Core/Installer.class.php
This commit is contained in:
nuxsmin
2017-02-20 19:20:39 +01:00
28 changed files with 278 additions and 190 deletions

View File

@@ -55,6 +55,8 @@ class AccountCrypt
*/
public function updateOldPass(&$currentMasterPass)
{
set_time_limit(300);
$accountsOk = [];
$userId = Session::getUserData()->getUserId();
$demoEnabled = Checks::demoIsEnabled();

View File

@@ -55,6 +55,8 @@ class AccountHistoryCrypt
*/
public function updateOldPass(&$currentMasterPass)
{
set_time_limit(300);
$accountsOk = [];
$demoEnabled = Checks::demoIsEnabled();
$errorCount = 0;

View File

@@ -653,8 +653,8 @@ class ConfigActionController implements ItemControllerInterface
}
$ImportParams = new ImportParams();
$ImportParams->setDefaultUser(Request::analyze('defUser', Session::getUserData()->getUserId()));
$ImportParams->setDefaultGroup(Request::analyze('defGroup', Session::getUserData()->getUserGroupId()));
$ImportParams->setDefaultUser(Request::analyze('import_defaultuser', Session::getUserData()->getUserId()));
$ImportParams->setDefaultGroup(Request::analyze('import_defaultgroup', Session::getUserData()->getUserGroupId()));
$ImportParams->setImportPwd(Request::analyzeEncrypted('importPwd'));
$ImportParams->setImportMasterPwd(Request::analyzeEncrypted('importMasterPwd'));
$ImportParams->setCsvDelimiter(Request::analyze('csvDelimiter'));

View File

@@ -58,8 +58,6 @@ class MainActionController
&& $hash === Config::getConfig()->getUpgradeKey()
) {
$this->upgrade($dbVersion, 'db');
ConfigDB::setValue('version', implode(Util::getVersion(true)));
} else {
$controller = new MainController();
$controller->getUpgrade($dbVersion);
@@ -103,7 +101,7 @@ class MainActionController
private function upgrade($version, $type)
{
try {
Upgrade::doUpgrade($version, $type);
Upgrade::doUpgrade($version);
$Config = Config::getConfig();
$Config->setMaintenance(false);

View File

@@ -507,7 +507,9 @@ class Init
*/
public static function isLoggedIn()
{
return (DiFactory::getDBStorage()->getDbStatus() === 0 && Session::getUserData()->getUserLogin());
return (DiFactory::getDBStorage()->getDbStatus() === 0
&& Session::getUserData()->getUserLogin()
&& is_object(Session::getUserPreferences()));
}
/**

View File

@@ -0,0 +1,64 @@
<?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/>.
*/
namespace SP\Core\Upgrade;
use SP\Core\Exceptions\SPException;
use SP\Storage\DB;
use SP\Storage\QueryData;
/**
* Class Account
*
* @package SP\Core\Upgrade
*/
class Account
{
/**
* Actualizar registros con usuarios no existentes
*
* @return bool
*/
public static function fixAccountsId()
{
try {
DB::beginTransaction();
$Data = new QueryData();
$query = /** @lang SQL */
'DELETE FROM accUsers WHERE accuser_accountId NOT IN (SELECT account_id FROM accounts) OR accuser_accountId IS NULL';
$Data->setQuery($query);
DB::getQuery($Data);
DB::endTransaction();
return true;
} catch (SPException $e) {
DB::rollbackTransaction();
return false;
}
}
}

View File

@@ -71,12 +71,12 @@ class Category
DB::getQuery($Data);
DB::endTransaction();
return true;
} catch (SPException $e) {
DB::rollbackTransaction();
return false;
}
return true;
}
}

View File

@@ -51,18 +51,26 @@ class Crypt
public static function migrate(&$masterPass)
{
try {
DB::beginTransaction();
if (!DB::beginTransaction()) {
throw new SPException(SPException::SP_ERROR, __('No es posible iniciar una transacción', false));
}
self::migrateAccounts($masterPass);
self::migrateCustomFields($masterPass);
DB::endTransaction();
if (!DB::endTransaction()) {
throw new SPException(SPException::SP_ERROR, __('No es posible finalizar una transacción', false));
}
} catch (CryptoException $e) {
DB::rollbackTransaction();
if (DB::rollbackTransaction()) {
debugLog('Rollback');
}
return false;
} catch (SPException $e) {
DB::rollbackTransaction();
if (DB::rollbackTransaction()) {
debugLog('Rollback');
}
return false;
}

View File

@@ -71,12 +71,12 @@ class Customer
DB::getQuery($Data);
DB::endTransaction();
return true;
} catch (SPException $e) {
DB::rollbackTransaction();
return false;
}
return true;
}
}

View File

@@ -63,12 +63,12 @@ class Group
DB::getQuery($Data);
DB::endTransaction();
return true;
} catch (SPException $e) {
DB::rollbackTransaction();
return false;
}
return true;
}
}

View File

@@ -65,12 +65,12 @@ class Profile
DB::getQuery($Data);
DB::endTransaction();
return true;
} catch (SPException $e) {
DB::rollbackTransaction();
return false;
}
return true;
}
}

View File

@@ -52,7 +52,7 @@ defined('APP_ROOT') || die();
*/
class Upgrade
{
private static $dbUpgrade = [110, 1121, 1122, 1123, 11213, 11219, 11220, 12001, 12002, 1316011001, 1316020501, 1316100601, 20017011302, 20017011701, 20017012901, 20117021901];
private static $dbUpgrade = [110, 1121, 1122, 1123, 11213, 11219, 11220, 12001, 12002, 1316011001, 1316100601, 20017011302, 20017011701, 20017012901, 20117021901];
private static $cfgUpgrade = [1124, 1316020501, 20017011202];
private static $auxUpgrade = [12001, 12002, 20017010901, 20017011202];
private static $appUpgrade = [20117021901];
@@ -61,34 +61,32 @@ class Upgrade
* Inicia el proceso de actualización de la BBDD.
*
* @param int $version con la versión de la BBDD actual
* @param $type
* @return bool
* @throws SPException
*/
public static function doUpgrade($version, $type)
public static function doUpgrade($version)
{
if ($type === 'db') {
foreach (self::$dbUpgrade as $upgradeVersion) {
if ($version < $upgradeVersion) {
if (self::auxPreDbUpgrade($upgradeVersion) === false) {
throw new SPException(SPException::SP_CRITICAL,
__('Error al aplicar la actualización auxiliar', false),
__('Compruebe el registro de eventos para más detalles', false));
}
if (self::upgradeDB($upgradeVersion) === false) {
throw new SPException(SPException::SP_CRITICAL, __('Error al aplicar la actualización de la Base de Datos', false),
__('Compruebe el registro de eventos para más detalles', false));
}
}
}
} elseif ($type === 'app') {
foreach (self::$appUpgrade as $upgradeVersion) {
if ($version < $upgradeVersion && self::appUpgrades($upgradeVersion) === false) {
foreach (self::$dbUpgrade as $upgradeVersion) {
if ($version < $upgradeVersion) {
if (self::auxPreDbUpgrade($upgradeVersion) === false) {
throw new SPException(SPException::SP_CRITICAL,
__('Error al aplicar la actualización de la aplicación', false),
__('Error al aplicar la actualización auxiliar', false),
__('Compruebe el registro de eventos para más detalles', false));
}
if (self::upgradeDB($upgradeVersion) === false) {
throw new SPException(SPException::SP_CRITICAL,
__('Error al aplicar la actualización de la Base de Datos', false),
__('Compruebe el registro de eventos para más detalles', false));
}
}
}
foreach (self::$appUpgrade as $upgradeVersion) {
if ($version < $upgradeVersion && self::appUpgrades($upgradeVersion) === false) {
throw new SPException(SPException::SP_CRITICAL,
__('Error al aplicar la actualización de la aplicación', false),
__('Compruebe el registro de eventos para más detalles', false));
}
}
@@ -113,8 +111,11 @@ class Upgrade
{
switch ($version) {
case 1316011001:
return self::upgradeDB(1300000000);
case 1316100601:
return
UserUpgrade::fixUsersId(Request::analyze('userid', 1))
Account::fixAccountsId()
&& UserUpgrade::fixUsersId(Request::analyze('userid', 1))
&& Group::fixGroupId(Request::analyze('groupid', 1))
&& Profile::fixProfilesId(Request::analyze('profileid', 1))
&& Category::fixCategoriesId(Request::analyze('categoryid', 1))
@@ -139,7 +140,7 @@ class Upgrade
$queries = self::getQueriesFromFile($version);
if (count($queries) === 0) {
if (count($queries) === 0 || (int)ConfigDB::getValue('version') === $version) {
$LogMessage->addDescription(__('No es necesario actualizar la Base de Datos.', false));
$Log->writeLog();
return true;
@@ -162,6 +163,8 @@ class Upgrade
}
}
ConfigDB::setValue('version', $version);
$LogMessage->addDescription(__('Actualización de la Base de Datos realizada correctamente.', false));
$Log->writeLog();
@@ -210,9 +213,7 @@ class Upgrade
$databaseVersion = (int)str_replace('.', '', ConfigDB::getValue('version'));
if ($databaseVersion < $version) {
if (self::upgradeDB($version)) {
ConfigDB::setValue('version', $version);
} else {
if (!self::upgradeDB($version)) {
$dbResult = false;
}
}
@@ -225,8 +226,8 @@ class Upgrade
return $dbResult === true
&& is_object($UserData)
&& !empty($masterPass)
&& Crypt::migrateHash($masterPass)
&& Crypt::migrate($masterPass)
&& Crypt::migrateHash($masterPass)
&& UserMigrate::setMigrateUsers();
}
} catch (SPException $e) {

View File

@@ -93,14 +93,26 @@ class User
DB::getQuery($Data);
$query = /** @lang SQL */
'DELETE FROM usrToGroups WHERE usertogroup_userId <> ? AND usertogroup_userId NOT IN (' . $paramsIn . ') OR usertogroup_userId IS NULL';
$Data->setQuery($query);
DB::getQuery($Data);
$query = /** @lang SQL */
'DELETE FROM accUsers WHERE accuser_userId <> ? AND accuser_userId NOT IN (' . $paramsIn . ') OR accuser_userId IS NULL';
$Data->setQuery($query);
DB::getQuery($Data);
DB::endTransaction();
return true;
} catch (SPException $e) {
DB::rollbackTransaction();
return false;
}
return true;
}
/**

View File

@@ -128,7 +128,9 @@ class AccountForm extends FormBase implements FormInterface
*/
protected function checkPass()
{
if (!$this->AccountData->getAccountPass()) {
if ($this->AccountData->getAccountParentId() > 0) {
return;
} elseif (!$this->AccountData->getAccountPass()) {
throw new ValidationException(__('Es necesaria una clave', false));
} elseif (Request::analyzeEncrypted('passR') !== $this->AccountData->getAccountPass()) {
throw new ValidationException(__('Las claves no coinciden', false));

View File

@@ -24,7 +24,6 @@
namespace SP\Import;
use Import\XmlFileImport;
use SP\Core\Exceptions\SPException;
defined('APP_ROOT') || die();

View File

@@ -45,6 +45,10 @@ class Log extends ActionLog
* @var int
*/
public static $numRows = 0;
/**
* @var int
*/
private static $logDbEnabled = 1;
/**
* Obtener los eventos guardados.
@@ -120,6 +124,7 @@ class Log extends ActionLog
public function writeLog($resetDescription = false)
{
if ((defined('IS_INSTALLER') && IS_INSTALLER === 1)
|| self::$logDbEnabled === 0
|| DiFactory::getDBStorage()->getDbStatus() === 1
) {
debugLog('Action: ' . $this->LogMessage->getAction() . ' -- Description: ' . $this->LogMessage->getDescription() . ' -- Details: ' . $this->LogMessage->getDetails());
@@ -164,8 +169,11 @@ class Log extends ActionLog
try {
DB::getQuery($Data);
} catch (SPException $e) {
debugLog($e->getMessage(), true);
debugLog($e->getHint());
debugLog(__($e->getMessage()), true);
debugLog(__($e->getHint()));
// Desactivar el log a BD si falla
self::$logDbEnabled = 0;
}
Language::unsetAppLocales();

View File

@@ -30,6 +30,7 @@ use SP\Core\DiFactory;
use SP\Core\Exceptions\ConstraintException;
use SP\Core\Exceptions\QueryException;
use SP\Core\Exceptions\SPException;
use SP\Core\Messages\LogMessage;
use SP\Log\Log;
use SP\Util\Util;
@@ -249,7 +250,7 @@ class DB
debugLog('Exception: ' . $e->getMessage());
debugLog(ob_get_clean());
throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), '', $e->getCode());
throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), '', $e->getCode(), $e);
}
}
@@ -290,17 +291,21 @@ class DB
{
$caller = Util::traceLastCall($queryFunction);
$Log = new Log();
$LogMessage = $Log->getLogMessage();
$LogMessage = new LogMessage();
$LogMessage->setAction($caller);
$LogMessage->addDescription(__('Error en la consulta', false));
$LogMessage->addDescription(sprintf('%s (%s)', $errorMsg, $errorCode));
$LogMessage->addDetails('SQL', DBUtil::escape($query));
$Log->setLogLevel(Log::ERROR);
$Log->writeLog();
debugLog($LogMessage->getDescription(), true);
debugLog($LogMessage->getDetails());
// Solo registrar eventos de ls BD si no son consultas del registro de eventos
if ($caller !== 'writeLog') {
$Log = new Log($LogMessage);
$Log->setLogLevel(Log::ERROR);
$Log->writeLog();
}
}
/**
@@ -345,6 +350,8 @@ class DB
try {
$db = new DB();
$db->doQuery($queryData);
return true;
} catch (SPException $e) {
$queryData->setQueryStatus($e->getCode());
@@ -352,12 +359,10 @@ class DB
if ($e->getCode() === 23000) {
throw new ConstraintException(SPException::SP_ERROR, __('Restricción de integridad', false), $e->getMessage(), $e->getCode());
} else {
throw new QueryException(SPException::SP_ERROR, $errorMessage, $e->getMessage(), $e->getCode());
}
}
return true;
throw new QueryException(SPException::SP_ERROR, $errorMessage, $e->getMessage(), $e->getCode());
}
}
/**

75
inc/sql/1300000000.sql Normal file
View File

@@ -0,0 +1,75 @@
ALTER TABLE `usrData` ENGINE = InnoDB;
ALTER TABLE `accFiles` ENGINE = InnoDB;
ALTER TABLE `accGroups` ENGINE = InnoDB;
ALTER TABLE `accHistory` ENGINE = InnoDB;
ALTER TABLE `accUsers` ENGINE = InnoDB;
ALTER TABLE `categories` ENGINE = InnoDB;
ALTER TABLE `config` ENGINE = InnoDB;
ALTER TABLE `customers` ENGINE = InnoDB;
ALTER TABLE `log` ENGINE = InnoDB;
ALTER TABLE `usrGroups` ENGINE = InnoDB;
ALTER TABLE `usrPassRecover` ENGINE = InnoDB;
ALTER TABLE `usrProfiles` ENGINE = InnoDB;
ALTER TABLE `accounts` ENGINE = InnoDB;
ALTER TABLE `log` ADD log_level VARCHAR(20) NOT NULL;
ALTER TABLE `config` CHANGE config_value config_value VARCHAR(2000);
CREATE TABLE IF NOT EXISTS `publicLinks` (
`publicLink_id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`publicLink_itemId` int UNSIGNED DEFAULT NULL,
`publicLink_hash` varbinary(100) NOT NULL,
`publicLink_linkData` longblob,
PRIMARY KEY (`publicLink_id`),
UNIQUE KEY `IDX_hash` (`publicLink_hash`),
UNIQUE KEY `unique_publicLink_hash` (`publicLink_hash`),
UNIQUE KEY `unique_publicLink_accountId` (`publicLink_itemId`),
KEY `IDX_itemId` (`publicLink_itemId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `accFavorites` (
`accfavorite_accountId` smallint(5) unsigned NOT NULL,
`accfavorite_userId` smallint(5) unsigned NOT NULL,
KEY `fk_accFavorites_accounts_idx` (`accfavorite_accountId`),
KEY `fk_accFavorites_users_idx` (`accfavorite_userId`),
KEY `search_idx` (`accfavorite_accountId`,`accfavorite_userId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tags` (
`tag_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`tag_name` VARCHAR(45) NOT NULL,
`tag_hash` BINARY(40) NOT NULL,
PRIMARY KEY (`tag_id`),
INDEX `IDX_name` (`tag_name` ASC),
UNIQUE INDEX `tag_hash_UNIQUE` (`tag_hash` ASC)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
CREATE TABLE IF NOT EXISTS `accTags` (
`acctag_accountId` SMALLINT(10) UNSIGNED NOT NULL,
`acctag_tagId` INT UNSIGNED NOT NULL,
INDEX `IDX_id` (`acctag_accountId` ASC, `acctag_tagId` ASC)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
CREATE TABLE IF NOT EXISTS `plugins` (
`plugin_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`plugin_name` VARCHAR(100) NOT NULL,
`plugin_data` VARBINARY(5000) NULL,
`plugin_enabled` BIT(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`plugin_id`),
UNIQUE INDEX `plugin_name_UNIQUE` (`plugin_name` ASC)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
CREATE TABLE IF NOT EXISTS `notices` (
`notice_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`notice_type` VARCHAR(100) NULL,
`notice_component` VARCHAR(100) NOT NULL,
`notice_description` VARCHAR(500) NOT NULL,
`notice_date` INT UNSIGNED NOT NULL,
`notice_checked` BIT(1) NULL DEFAULT b'0',
`notice_userId` SMALLINT(5) UNSIGNED NULL,
`notice_sticky` BIT(1) NULL DEFAULT b'0',
`notice_onlyAdmin` BIT(1) NULL DEFAULT b'0',
PRIMARY KEY (`notice_id`),
INDEX `IDX_userId` (`notice_userId` ASC, `notice_checked` ASC, `notice_date` ASC),
INDEX `IDX_component` (`notice_component` ASC, `notice_date` ASC, `notice_checked` ASC, `notice_userId` ASC)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;

View File

@@ -1,50 +0,0 @@
-- To 1.3.16011001;
ALTER TABLE `log`
ADD log_level VARCHAR(20) NOT NULL;
CREATE TABLE `publicLinks` (
publicLink_id INT UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
publicLink_itemId INT UNSIGNED,
publicLink_hash VARBINARY(100) NOT NULL,
publicLink_linkData LONGBLOB
);
ALTER TABLE `usrData`
ENGINE = InnoDB;
ALTER TABLE `accFiles`
ENGINE = InnoDB;
ALTER TABLE `accGroups`
ENGINE = InnoDB;
ALTER TABLE `accHistory`
ENGINE = InnoDB;
ALTER TABLE `accUsers`
ENGINE = InnoDB;
ALTER TABLE `categories`
ENGINE = InnoDB;
ALTER TABLE `config`
ENGINE = InnoDB;
ALTER TABLE `customers`
ENGINE = InnoDB;
ALTER TABLE `log`
ENGINE = InnoDB;
ALTER TABLE `usrGroups`
ENGINE = InnoDB;
ALTER TABLE `usrPassRecover`
ENGINE = InnoDB;
ALTER TABLE `usrProfiles`
ENGINE = InnoDB;
ALTER TABLE `accounts`
ENGINE = InnoDB;
CREATE UNIQUE INDEX unique_publicLink_accountId
ON publicLinks (publicLink_itemId);
CREATE UNIQUE INDEX unique_publicLink_hash
ON publicLinks (publicLink_hash);
ALTER TABLE `config`
CHANGE config_value config_value VARCHAR(2000);
CREATE TABLE `accFavorites` (
`accfavorite_accountId` SMALLINT UNSIGNED NOT NULL,
`accfavorite_userId` SMALLINT UNSIGNED NOT NULL,
INDEX `fk_accFavorites_accounts_idx` (`accfavorite_accountId` ASC),
INDEX `fk_accFavorites_users_idx` (`accfavorite_userId` ASC),
INDEX `search_idx` (`accfavorite_accountId` ASC, `accfavorite_userId` ASC)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;

View File

@@ -1,19 +0,0 @@
-- To 1.3.16020501;
CREATE TABLE `tags` (
`tag_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`tag_name` VARCHAR(45) NOT NULL,
`tag_hash` BINARY(20) NOT NULL,
PRIMARY KEY (`tag_id`),
INDEX `IDX_name` (`tag_name` ASC),
UNIQUE INDEX `tag_hash_UNIQUE` (`tag_hash` ASC)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `accTags` (
`acctag_accountId` INT UNSIGNED NOT NULL,
`acctag_tagId` INT UNSIGNED NOT NULL,
INDEX `IDX_id` (`acctag_accountId` ASC),
INDEX `fk_accTags_tags_id_idx` (`acctag_tagId` ASC)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;

View File

@@ -11,9 +11,6 @@ ALTER TABLE `accHistory`
ADD INDEX `fk_accHistory_categories_id_idx` (`acchistory_categoryId` ASC),
ADD INDEX `fk_accHistory_customers_id_idx` (`acchistory_customerId` ASC);
ALTER TABLE `accTags`
CHANGE COLUMN `acctag_accountId` `acctag_accountId` SMALLINT(10) UNSIGNED NOT NULL;
ALTER TABLE `accUsers`
DROP COLUMN `accuser_id`,
CHANGE COLUMN `accuser_accountId` `accuser_accountId` SMALLINT(5) UNSIGNED NOT NULL,
@@ -34,6 +31,7 @@ ALTER TABLE `accounts`
ALTER TABLE `authTokens`
CHANGE COLUMN `authtoken_userId` `authtoken_userId` SMALLINT(5) UNSIGNED NOT NULL,
ADD INDEX `fk_authTokens_users_id_idx` (`authtoken_userId` ASC, `authtoken_createdBy` ASC);
ALTER TABLE `log`
CHANGE COLUMN `log_userId` `log_userId` SMALLINT(5) UNSIGNED NOT NULL,
CHANGE COLUMN `log_description` `log_description` TEXT NULL DEFAULT NULL,
@@ -61,8 +59,8 @@ ALTER TABLE `usrToGroups`
DROP PRIMARY KEY;
ALTER TABLE `accGroups`
CHANGE COLUMN `accgroup_accountId` `accgroup_accountId` SMALLINT(5) UNSIGNED NOT NULL ,
CHANGE COLUMN `accgroup_groupId` `accgroup_groupId` SMALLINT(5) UNSIGNED NOT NULL;
CHANGE COLUMN `accgroup_accountId` `accgroup_accountId` SMALLINT(5) UNSIGNED NOT NULL,
CHANGE COLUMN `accgroup_groupId` `accgroup_groupId` SMALLINT(5) UNSIGNED NOT NULL;
ALTER TABLE `accFavorites`
ADD CONSTRAINT `fk_accFavorites_accounts_id`
@@ -278,9 +276,7 @@ ALTER TABLE `accHistory`
AFTER `accHistory_passDateChange`,
ADD INDEX `fk_accHistory_userGroup_id_idx` (`acchistory_userGroupId` ASC);
CREATE OR REPLACE ALGORITHM = UNDEFINED
DEFINER = CURRENT_USER
SQL SECURITY DEFINER VIEW `account_data_v` AS
CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_data_v` AS
SELECT
`accounts`.`account_id` AS `account_id`,
`accounts`.`account_name` AS `account_name`,
@@ -318,9 +314,7 @@ CREATE OR REPLACE ALGORITHM = UNDEFINED
ON ((`accounts`.`account_customerId` = `customers`.`customer_id`))) LEFT JOIN `publicLinks`
ON ((`accounts`.`account_id` = `publicLinks`.`publicLink_itemId`)));
CREATE OR REPLACE ALGORITHM = UNDEFINED
DEFINER = CURRENT_USER
SQL SECURITY DEFINER VIEW `account_search_v` AS
CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_search_v` AS
SELECT DISTINCT
`accounts`.`account_id` AS `account_id`,
`accounts`.`account_customerId` AS `account_customerId`,
@@ -357,28 +351,4 @@ ALTER TABLE `accounts`
ALTER TABLE `categories`
ADD COLUMN `category_hash` VARBINARY(40) NOT NULL DEFAULT 0
AFTER `category_description`;
CREATE TABLE `plugins` (
`plugin_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`plugin_name` VARCHAR(100) NOT NULL,
`plugin_data` VARBINARY(5000) NULL,
`plugin_enabled` BIT(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`plugin_id`),
UNIQUE INDEX `plugin_name_UNIQUE` (`plugin_name` ASC)
);
CREATE TABLE `notices` (
`notice_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`notice_type` VARCHAR(100) NULL,
`notice_component` VARCHAR(100) NOT NULL,
`notice_description` VARCHAR(500) NOT NULL,
`notice_date` INT UNSIGNED NOT NULL,
`notice_checked` BIT(1) NULL DEFAULT b'0',
`notice_userId` SMALLINT(5) UNSIGNED NULL,
`notice_sticky` BIT(1) NULL DEFAULT b'0',
`notice_onlyAdmin` BIT(1) NULL DEFAULT b'0',
PRIMARY KEY (`notice_id`),
INDEX `IDX_userId` (`notice_userId` ASC, `notice_checked` ASC, `notice_date` ASC),
INDEX `IDX_component` (`notice_component` ASC, `notice_date` ASC, `notice_checked` ASC, `notice_userId` ASC)
);
AFTER `category_description`;

View File

@@ -1 +1,2 @@
ALTER TABLE `accounts` CHANGE COLUMN `account_id` `account_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `accounts`
CHANGE COLUMN `account_id` `account_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT;

View File

@@ -1,8 +1,9 @@
ALTER TABLE `accounts` ADD COLUMN `account_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `account_isPrivate`;
ALTER TABLE `accHistory` ADD COLUMN `accHistory_isPrivate` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_parentId`,
ADD COLUMN `accHistory_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_isPrivate`;
ALTER TABLE `accounts`
ADD COLUMN `account_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `account_isPrivate`;
ALTER TABLE `accHistory`
ADD COLUMN `accHistory_isPrivate` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_parentId`,
ADD COLUMN `accHistory_isPrivateGroup` BIT(1) NULL DEFAULT b'0' AFTER `accHistory_isPrivate`;
CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFINER VIEW `account_data_v` AS
SELECT

View File

@@ -37,4 +37,4 @@ CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = CURRENT_USER SQL SECURITY DEFI
(((`accounts`
LEFT JOIN `categories` ON ((`accounts`.`account_categoryId` = `categories`.`category_id`)))
LEFT JOIN `usrGroups` `ug` ON ((`accounts`.`account_userGroupId` = `ug`.`usergroup_id`)))
LEFT JOIN `customers` ON ((`customers`.`customer_id` = `accounts`.`account_customerId`)))
LEFT JOIN `customers` ON ((`customers`.`customer_id` = `accounts`.`account_customerId`)));

View File

@@ -1,5 +1,10 @@
ALTER TABLE `accounts` CHANGE COLUMN `account_IV` `account_key` VARBINARY(500) NOT NULL ;
ALTER TABLE `accHistory` CHANGE COLUMN `acchistory_IV` `acchistory_key` VARBINARY(500) NOT NULL ;
ALTER TABLE `customFieldsData` CHANGE COLUMN `customfielddata_iv` `customfielddata_key` VARBINARY(500) NOT NULL;
ALTER TABLE `usrData` CHANGE COLUMN `user_mPass` `user_mKey` VARBINARY(500) NULL DEFAULT NULL, CHANGE COLUMN `user_mIV` `user_mKey` VARBINARY(500) NULL DEFAULT NULL;
ALTER TABLE `accounts`
CHANGE COLUMN `account_IV` `account_key` VARBINARY(1000) NOT NULL ;
ALTER TABLE `accHistory`
CHANGE COLUMN `acchistory_IV` `acchistory_key` VARBINARY(1000) NOT NULL ;
ALTER TABLE `customFieldsData`
CHANGE COLUMN `customfielddata_iv` `customfielddata_key` VARBINARY(1000) NOT NULL;
ALTER TABLE `usrData`
CHANGE COLUMN `user_mPass` `user_mPass` VARBINARY(1000) NULL DEFAULT NULL,
CHANGE COLUMN `user_mIV` `user_mKey` VARBINARY(1000) NULL DEFAULT NULL;

View File

@@ -222,6 +222,19 @@ CREATE TABLE `accHistory` (
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tags` (
`tag_id` int unsigned NOT NULL AUTO_INCREMENT,
`tag_name` varchar(45) NOT NULL,
`tag_hash` binary(40) NOT NULL,
PRIMARY KEY (`tag_id`),
UNIQUE KEY `tag_hash_UNIQUE` (`tag_hash`),
KEY `IDX_name` (`tag_name`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `accTags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -341,19 +354,6 @@ CREATE TABLE `publicLinks` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tags` (
`tag_id` int unsigned NOT NULL AUTO_INCREMENT,
`tag_name` varchar(45) NOT NULL,
`tag_hash` binary(40) NOT NULL,
PRIMARY KEY (`tag_id`),
UNIQUE KEY `tag_hash_UNIQUE` (`tag_hash`),
KEY `IDX_name` (`tag_name`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `usrPassRecover`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;

View File

@@ -349,10 +349,12 @@ sysPass.Triggers = function (Common) {
if ($this[0].value > 0) {
$pass.each(function () {
$(this).prop("disabled", "true");
$(this).prop("required", "false");
});
} else {
$pass.each(function () {
$(this).prop("disabled", "");
$(this).prop("required", "true");
});
}
});

View File

@@ -7,7 +7,7 @@ var a=$("#frmSearch");0!==a.length&&(a.find("select, #rpp").on("change",function
passreset:function(){d.info("views:passreset");var a=$("#frmPassReset");b.appTheme().passwordDetect(a)},footer:function(){d.info("views:footer");$("#btnLogout").click(function(a){b.appActions().main.logout()});$("#btnPrefs").click(function(a){b.appActions().doAction({actionId:$(this).data("action-id")})})},common:function(a){d.info("views:common");e(a);"function"===typeof b.appTheme().viewsTriggers.common&&b.appTheme().viewsTriggers.common(a);b.appTriggers().updateFormHash(a)},datatabs:function(a){d.info("views:datatabs");
$(".datagrid-action-search>form").each(function(){var a=$(this);a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.trigger("reset")})})},config:function(){d.info("views:config");var a=$("#drop-import-files");if(0<a.length){var c=b.fileUpload(a);c.url=b.appActions().ajaxUrl.config["import"];c.beforeSendAction=function(){c.setRequestData({sk:b.sk.get(),csvDelimiter:$("#csvDelimiter").val(),importPwd:$("#importPwd").val(),importMasterPwd:$("#importMasterPwd").val(),import_defaultuser:$("#import_defaultuser").val(),
import_defaultgroup:$("#import_defaultgroup").val()})}}},account:function(){d.info("views:account");var a=$("#list-account-files");0<a.length&&b.appActions().account.getfiles(a);var c=$("#drop-account-files");0<c.length&&(c=b.fileUpload(c),c.url=b.appActions().ajaxUrl.file,c.requestDoneAction=function(){b.appActions().account.getfiles(a)});c=$(".show-extra-info");if(0<c.length)c.on("click",function(){var a=$(this),b=$(a.data("target"));b.is(":hidden")?(b.slideDown("slow"),a.html(a.data("icon-up"))):
(b.slideUp("slow"),a.html(a.data("icon-down")))});c=$("#selParentAccount");0<c.length&&(c.on("change",function(){var a=$(this),b=$("#accountpass,#accountpassR");0<a[0].value?b.each(function(){$(this).prop("disabled","true")}):b.each(function(){$(this).prop("disabled","")})}),b.appActions().items.get(c))},install:function(){d.info("views:install");var a=$("#frmInstall");b.appTheme().passwordDetect(a);e(a)}},selectDetect:e,updateSk:function(){$("#content").find("[data-sk]").each(function(){d.info("updateSk");
(b.slideUp("slow"),a.html(a.data("icon-down")))});c=$("#selParentAccount");0<c.length&&(c.on("change",function(){var a=$(this),b=$("#accountpass,#accountpassR");0<a[0].value?b.each(function(){$(this).prop("disabled","true");$(this).prop("required","false")}):b.each(function(){$(this).prop("disabled","");$(this).prop("required","true")})}),b.appActions().items.get(c))},install:function(){d.info("views:install");var a=$("#frmInstall");b.appTheme().passwordDetect(a);e(a)}},selectDetect:e,updateSk:function(){$("#content").find("[data-sk]").each(function(){d.info("updateSk");
$(this).data("sk",b.sk.get())})},updateFormHash:function(a){d.info("updateFormHash");a=void 0!==a?a.find(".form-action[data-hash]"):$(".form-action[data-hash]");0<a.length&&a.each(function(){var a=$(this);a.attr("data-hash",SparkMD5.hash(a.serialize(),!1))})},bodyHooks:function(){d.info("bodyHooks");$("body").on("click",".btn-action[data-onclick],.btn-action-pager[data-onclick]",function(){var a=$(this),c=a.data("onclick").split("/"),d=b.appActions();if(2===c.length)d[c[0]][c[1]](a);else d[c[0]](a)}).on("click",
".btn-back",function(){var a=b.appRequests();if(0<a.history.length()){d.info("back");var c=a.history.del();a.getActionCall(c,c.callback)}}).on("submit",".form-action",function(a){a.preventDefault();a=$(this);d.info("formAction");var c=a.attr("data-hash"),e=SparkMD5.hash(a.serialize(),!1);if(c===e)b.msg.ok(b.config().LANG[55]);else if(c=a.data("plugin"),c="undefined"!==typeof c?sysPass.Plugin[c](b):b.appActions(),e=a.data("onsubmit").split("/"),a.find("input[name='sk']").val(b.sk.get()),2===e.length)c[e[0]][e[1]](a);
else c[e[0]](a)}).on("click",".btn-help",function(){var a=$(this),a=$("#"+a.data("help")).html();showDialog({title:b.config().LANG[54],text:a,positive:{title:b.config().LANG[43]}})}).on("reset",".form-action",function(a){a.preventDefault();d.info("reset");a=$(this);a.find("input:text, input:password, input:file, textarea").val("").parent("div").removeClass("is-dirty");a.find("input:radio, input:checkbox").removeAttr("checked").removeAttr("selected");a.find("input[name='start'], input[name='skey'], input[name='sorder']").val(0);