Exemplo n.º 1
0
 /**
  * Comprobar si el usuario tiene actualizada la clave maestra actual.
  *
  * @param string $login opcional con el login del usuario
  * @return bool
  */
 public static function checkUserUpdateMPass($login = null)
 {
     $userId = !is_null($login) ? UserUtil::getUserIdByLogin($login) : Session::getUserId();
     if ($userId === 0) {
         return false;
     }
     $configMPassTime = ConfigDB::getValue('lastupdatempass');
     if ($configMPassTime === false) {
         return false;
     }
     $query = 'SELECT user_lastUpdateMPass FROM usrData WHERE user_id = :id LIMIT 1';
     $data['id'] = $userId;
     $queryRes = DB::getResults($query, __FUNCTION__, $data);
     $ret = $queryRes !== false && $queryRes->user_lastUpdateMPass > $configMPassTime;
     return $ret;
 }
Exemplo n.º 2
0
 /**
  * Actualizar la clave maestra del usuario en la BBDD.
  *
  * @param string $masterPwd con la clave maestra
  * @return bool
  */
 public function updateUserMPass($masterPwd)
 {
     $configHashMPass = ConfigDB::getValue('masterPwd');
     if ($configHashMPass === false) {
         return false;
     }
     if (is_null($configHashMPass)) {
         $configHashMPass = Crypt::mkHashPassword($masterPwd);
         ConfigDB::setValue('masterPwd', $configHashMPass);
     }
     if (Crypt::checkHashPass($masterPwd, $configHashMPass, true)) {
         $cryptMPass = Crypt::mkCustomMPassEncrypt(self::getCypherPass(), $masterPwd);
         if (!$cryptMPass) {
             return false;
         }
     } else {
         return false;
     }
     $query = 'UPDATE usrData SET ' . 'user_mPass = :mPass,' . 'user_mIV = :mIV,' . 'user_lastUpdateMPass = UNIX_TIMESTAMP() ' . 'WHERE user_id = :id LIMIT 1';
     $data['mPass'] = $cryptMPass[0];
     $data['mIV'] = $cryptMPass[1];
     $data['id'] = $this->_userId;
     return DB::getQuery($query, __FUNCTION__, $data);
 }
Exemplo n.º 3
0
 /**
  * Actualiza el hash de las cuentas en el histórico.
  *
  * @param $newHash string El nuevo hash de la clave maestra
  * @return bool
  */
 public static function updateAccountsMPassHash($newHash)
 {
     $query = 'UPDATE accHistory SET ' . 'acchistory_mPassHash = :newHash ' . 'WHERE acchistory_mPassHash = :oldHash';
     $data['newHash'] = $newHash;
     $data['oldHash'] = ConfigDB::getValue('masterPwd');
     return DB::getQuery($query, __FUNCTION__, $data);
 }
Exemplo n.º 4
0
 /**
  * Devuelve la clave maestra que ha sido encriptada con la clave temporal
  *
  * @param $pass string con la clave utilizada para encriptar
  * @return string con la clave maestra desencriptada
  */
 public static function getTempMasterPass($pass)
 {
     $passLogin = hex2bin(ConfigDB::getValue('tempmaster_pass'));
     $passLoginIV = hex2bin(ConfigDB::getValue('tempmaster_passiv'));
     return Crypt::getDecrypt($passLogin, $passLoginIV, $pass);
 }
 /**
  * Crear un nuevo registro de histório de cuenta en la BBDD.
  *
  * @param int  $id       el id de la cuenta primaria
  * @param bool $isDelete indica que la cuenta es eliminada
  * @return bool
  */
 public static function addHistory($id, $isDelete = false)
 {
     $query = 'INSERT INTO accHistory ' . '(acchistory_accountId,' . 'acchistory_categoryId,' . 'acchistory_customerId,' . 'acchistory_name,' . 'acchistory_login,' . 'acchistory_url,' . 'acchistory_pass,' . 'acchistory_IV,' . 'acchistory_notes,' . 'acchistory_countView,' . 'acchistory_countDecrypt,' . 'acchistory_dateAdd,' . 'acchistory_dateEdit,' . 'acchistory_userId,' . 'acchistory_userGroupId,' . 'acchistory_userEditId,' . 'acchistory_otherUserEdit,' . 'acchistory_otherGroupEdit,' . 'acchistory_isModify,' . 'acchistory_isDeleted,' . 'acchistory_mPassHash) ' . 'SELECT account_id,' . 'account_categoryId,' . 'account_customerId,' . 'account_name,' . 'account_login,' . 'account_url,' . 'account_pass,' . 'account_IV,' . 'account_notes,' . 'account_countView,' . 'account_countDecrypt,' . 'account_dateAdd,' . 'account_dateEdit,' . 'account_userId,' . 'account_userGroupId,' . 'account_userEditId,' . 'account_otherUserEdit,' . 'account_otherGroupEdit,' . ':isModify,' . ':isDelete,' . ':masterPwd ' . 'FROM accounts WHERE account_id = :account_id';
     $data['account_id'] = $id;
     $data['isModify'] = $isDelete === false ? 1 : 0;
     $data['isDelete'] = $isDelete === false ? 0 : 1;
     $data['masterPwd'] = ConfigDB::getValue('masterPwd');
     return DB::getQuery($query, __FUNCTION__, $data);
 }