mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 08:34:16 +01:00
* [MOD] Improved layouts/templates handling. Work in progress.
* [MOD] Improved bootstrap workflow. Work in progress. * [MOD] Improved installer workflow. Work in progress.
This commit is contained in:
@@ -630,7 +630,7 @@ class Bootstrap
|
||||
CryptSession::reKey();
|
||||
|
||||
// Recargar los permisos del perfil de usuario
|
||||
$this->session->setUserProfile(Profile::getItem()->getById($this->session->getUserData()->getUserProfileId()));
|
||||
// $this->session->setUserProfile(Profile::getItem()->getById($this->session->getUserData()->getUserProfileId()));
|
||||
} catch (CryptoException $e) {
|
||||
debugLog($e->getMessage());
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ use SP\Core\Exceptions\InvalidArgumentException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Traits\InjectableTrait;
|
||||
use SP\DataModel\InstallData;
|
||||
use SP\DataModel\ProfileData;
|
||||
use SP\DataModel\UserData;
|
||||
use SP\DataModel\UserGroupData;
|
||||
use SP\DataModel\UserProfileData;
|
||||
@@ -339,6 +340,7 @@ class Installer
|
||||
|
||||
$userProfileData = new UserProfileData();
|
||||
$userProfileData->setName('Admin');
|
||||
$userProfileData->setProfile(new ProfileData());
|
||||
|
||||
// Datos del usuario
|
||||
$userData = new UserData();
|
||||
|
||||
@@ -26,12 +26,13 @@ namespace SP\Crypt;
|
||||
|
||||
use SP\Core\Crypt\Crypt;
|
||||
use SP\Core\Crypt\Hash;
|
||||
use SP\Core\Crypt\Session as CryptSession;
|
||||
use SP\Core\Events\EventDispatcher;
|
||||
use SP\Core\Session\Session;
|
||||
use SP\Core\Traits\InjectableTrait;
|
||||
use SP\DataModel\Dto\ConfigRequest;
|
||||
use SP\Services\Config\ConfigService;
|
||||
use SP\Core\Crypt\Session as CryptSession;
|
||||
use SP\Services\Config\ParameterNotFoundException;
|
||||
use SP\Services\ServiceException;
|
||||
use SP\Util\Util;
|
||||
|
||||
@@ -80,33 +81,37 @@ class TemporaryMasterPass
|
||||
*/
|
||||
public function check($pass)
|
||||
{
|
||||
$passMaxTime = (int)$this->configService->getByParam('tempmaster_maxtime');
|
||||
try {
|
||||
$passMaxTime = (int)$this->configService->getByParam('tempmaster_maxtime');
|
||||
|
||||
// Comprobar si el tiempo de validez o los intentos se han superado
|
||||
if ($passMaxTime === 0 || time() > $passMaxTime) {
|
||||
$this->expire();
|
||||
// Comprobar si el tiempo de validez o los intentos se han superado
|
||||
if ($passMaxTime === 0 || time() > $passMaxTime) {
|
||||
$this->expire();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$passTime = (int)$this->configService->getByParam('tempmaster_passtime');
|
||||
$attempts = (int)$this->configService->getByParam('tempmaster_attempts');
|
||||
|
||||
if ($attempts >= self::MAX_ATTEMPTS
|
||||
|| (!empty($passTime) && time() > $passMaxTime)
|
||||
) {
|
||||
$this->expire();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$isValid = Hash::checkHashKey($pass, $this->configService->getByParam('tempmaster_passhash'));
|
||||
|
||||
if (!$isValid) {
|
||||
$this->configService->save('tempmaster_attempts', $attempts + 1);
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
} catch (ParameterNotFoundException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$passTime = (int)$this->configService->getByParam('tempmaster_passtime');
|
||||
$attempts = (int)$this->configService->getByParam('tempmaster_attempts');
|
||||
|
||||
if ($attempts >= self::MAX_ATTEMPTS
|
||||
|| (!empty($passTime) && time() > $passMaxTime)
|
||||
) {
|
||||
$this->expire();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$isValid = Hash::checkHashKey($pass, $this->configService->getByParam('tempmaster_passhash'));
|
||||
|
||||
if (!$isValid) {
|
||||
$this->configService->save('tempmaster_attempts', $attempts + 1);
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ defined('APP_ROOT') || die();
|
||||
*
|
||||
* @package SP\DataModel
|
||||
*/
|
||||
class ProfileData extends UserProfileData
|
||||
class ProfileData
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -89,8 +89,8 @@ class UserProfileData extends DataModelBase implements DataModelInterface
|
||||
/**
|
||||
* @param ProfileData $profile
|
||||
*/
|
||||
public function setProfile($profile)
|
||||
public function setProfile(ProfileData $profile)
|
||||
{
|
||||
$this->profile = $profile;
|
||||
$this->profile = serialize($profile);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -35,7 +35,6 @@ use SP\Repositories\RepositoryItemInterface;
|
||||
use SP\Repositories\RepositoryItemTrait;
|
||||
use SP\Storage\DbWrapper;
|
||||
use SP\Storage\QueryData;
|
||||
use SP\Util\Util;
|
||||
|
||||
/**
|
||||
* Class UserProfileRepository
|
||||
@@ -118,7 +117,7 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
* Returns the item for given id
|
||||
*
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @return UserProfileData
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
@@ -126,27 +125,17 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
'SELECT id, name, profile FROM UserProfile WHERE id = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName(ProfileData::class);
|
||||
$Data->setMapClassName(UserProfileData::class);
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
/**
|
||||
* @var UserProfileData $queryRes
|
||||
* @var ProfileData $Profile
|
||||
*/
|
||||
$queryRes = DbWrapper::getResults($Data, $this->db);
|
||||
|
||||
$Profile = Util::unserialize(ProfileData::class, $queryRes->getProfile());
|
||||
$Profile->setId($queryRes->getId());
|
||||
$Profile->setName($queryRes->getName());
|
||||
|
||||
return $Profile;
|
||||
return DbWrapper::getResults($Data, $this->db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the items
|
||||
*
|
||||
* @return mixed
|
||||
* @return UserProfileData[]
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
@@ -230,7 +219,7 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
/**
|
||||
* Creates an item
|
||||
*
|
||||
* @param ProfileData $itemData
|
||||
* @param UserProfileData $itemData
|
||||
* @return int
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
@@ -250,8 +239,8 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($itemData->getName());
|
||||
$Data->addParam(serialize($itemData));
|
||||
$Data->setOnErrorMessage(__('Error al crear perfil', false));
|
||||
$Data->addParam($itemData->getProfile());
|
||||
$Data->setOnErrorMessage(__u('Error al crear perfil'));
|
||||
|
||||
DbWrapper::getQuery($Data, $this->db);
|
||||
|
||||
@@ -261,7 +250,7 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
/**
|
||||
* Checks whether the item is duplicated on adding
|
||||
*
|
||||
* @param ProfileData $itemData
|
||||
* @param UserProfileData $itemData
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
@@ -285,7 +274,7 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
/**
|
||||
* Updates an item
|
||||
*
|
||||
* @param ProfileData $itemData
|
||||
* @param UserProfileData $itemData
|
||||
* @return bool
|
||||
* @throws SPException
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
@@ -303,7 +292,7 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($itemData->getName());
|
||||
$Data->addParam(serialize($itemData));
|
||||
$Data->addParam($itemData->getProfile());
|
||||
$Data->addParam($itemData->getId());
|
||||
$Data->setOnErrorMessage(__u('Error al modificar perfil'));
|
||||
|
||||
@@ -319,7 +308,7 @@ class UserProfileRepository extends Repository implements RepositoryItemInterfac
|
||||
/**
|
||||
* Checks whether the item is duplicated on updating
|
||||
*
|
||||
* @param ProfileData $itemData
|
||||
* @param UserProfileData $itemData
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
|
||||
@@ -305,6 +305,9 @@ class LoginService
|
||||
* @throws SPException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws \ReflectionException
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
* @throws \SP\Services\Config\ParameterNotFoundException
|
||||
*/
|
||||
protected function loadMasterPass()
|
||||
{
|
||||
|
||||
@@ -27,8 +27,10 @@ namespace SP\Services\UserProfile;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Traits\InjectableTrait;
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\DataModel\ProfileData;
|
||||
use SP\Repositories\UserProfile\UserProfileRepository;
|
||||
use SP\Services\ServiceItemTrait;
|
||||
use SP\Util\Util;
|
||||
|
||||
/**
|
||||
* Class UserProfileService
|
||||
@@ -71,7 +73,7 @@ class UserProfileService
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
return $this->userProfileRepository->getById($id);
|
||||
return Util::unserialize(ProfileData::class, $this->userProfileRepository->getById($id)->getProfile());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user