Example #1
0
    SP\Response::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10);
}
$accountId = SP\Request::analyze('accountid', false);
$isHistory = SP\Request::analyze('isHistory', false);
if (!$accountId) {
    return;
}
$account = !$isHistory ? new SP\Account() : new SP\AccountHistory();
$account->setAccountParentId(\SP\Session::getAccountParentId());
$account->setAccountId($accountId);
$accountData = $account->getAccountPassData();
if ($isHistory && !$account->checkAccountMPass()) {
    SP\Response::printJSON(_('La clave maestra no coincide'));
}
if (!SP\Acl::checkAccountAccess(SP\Acl::ACTION_ACC_VIEW_PASS, $account->getAccountDataForACL()) || !SP\Acl::checkUserAccess(SP\Acl::ACTION_ACC_VIEW_PASS)) {
    SP\Response::printJSON(_('No tiene permisos para acceder a esta cuenta'));
} elseif (!UserPass::checkUserUpdateMPass()) {
    SP\Response::printJSON(_('Clave maestra actualizada') . '<br>' . _('Reinicie la sesión para cambiarla'));
}
$accountClearPass = SP\Crypt::getDecrypt($accountData->pass, $accountData->iv);
if (!$isHistory) {
    $account->incrementDecryptCounter();
    $log = new \SP\Log(_('Ver Clave'));
    $log->addDescription(_('ID') . ': ' . $accountId);
    $log->addDescription(_('Cuenta') . ': ' . $accountData->customer_name . " / " . $accountData->name);
    $log->writeLog();
}
//$accountPass = htmlspecialchars(trim($accountClearPass));
$useImage = intval(\SP\Util::accountPassToImageIsEnabled());
$data = array('title' => _('Clave de Cuenta'), 'acclogin' => $accountData->login, 'accpass' => !$useImage ? trim($accountClearPass) : \SP\ImageUtil::convertText($accountClearPass), 'useimage' => $useImage);
SP\Response::printJSON($data, 0);
Example #2
0
        SP\Response::printJSON(_('Es necesaria una clave'));
    }
} elseif ($actionId == \SP\Controller\ActionsInterface::ACTION_ACC_EDIT_RESTORE) {
    if (!$accountId) {
        SP\Response::printJSON(_('Id inválido'));
    }
} else {
    SP\Response::printJSON(_('Acción Inválida'));
}
if ($actionId == \SP\Controller\ActionsInterface::ACTION_ACC_NEW || $actionId == \SP\Controller\ActionsInterface::ACTION_ACC_COPY || $actionId === \SP\Controller\ActionsInterface::ACTION_ACC_EDIT_PASS) {
    if ($accountPassword != $accountPasswordR) {
        SP\Response::printJSON(_('Las claves no coinciden'));
    }
    // Encriptar clave de cuenta
    try {
        $accountEncPass = SP\Crypt::encryptData($accountPassword);
    } catch (\SP\SPException $e) {
        SP\Response::printJSON($e->getMessage());
    }
}
$Account = new SP\Account();
switch ($actionId) {
    case \SP\Controller\ActionsInterface::ACTION_ACC_NEW:
    case \SP\Controller\ActionsInterface::ACTION_ACC_COPY:
        SP\Customer::$customerName = $newCustomer;
        // Comprobar si se ha introducido un nuevo cliente
        if ($customerId === 0 && $newCustomer) {
            try {
                SP\Customer::addCustomer();
                $customerId = SP\Customer::$customerLastId;
            } catch (\SP\SPException $e) {
Example #3
0
 $noAccountPassChange = SP\Request::analyze('chkNoAccountChange', 0, false, 1);
 if (!UserPass::checkUserUpdateMPass()) {
     SP\Response::printJSON(_('Clave maestra actualizada') . ';;' . _('Reinicie la sesión para cambiarla'));
 } elseif ($newMasterPass == '' && $currentMasterPass == '') {
     SP\Response::printJSON(_('Clave maestra no indicada'));
 } elseif ($confirmPassChange == 0) {
     SP\Response::printJSON(_('Se ha de confirmar el cambio de clave'));
 }
 if ($newMasterPass == $currentMasterPass) {
     SP\Response::printJSON(_('Las claves son idénticas'));
 } elseif ($newMasterPass != $newMasterPassR) {
     SP\Response::printJSON(_('Las claves maestras no coinciden'));
 } elseif (!SP\Crypt::checkHashPass($currentMasterPass, ConfigDB::getValue('masterPwd'), true)) {
     SP\Response::printJSON(_('La clave maestra actual no coincide'));
 }
 $hashMPass = SP\Crypt::mkHashPassword($newMasterPass);
 if (!$noAccountPassChange) {
     $Account = new SP\Account();
     if (!$Account->updateAccountsMasterPass($currentMasterPass, $newMasterPass)) {
         SP\Response::printJSON(_('Errores al actualizar las claves de las cuentas'));
     }
     $AccountHistory = new SP\AccountHistory();
     if (!$AccountHistory->updateAccountsMasterPass($currentMasterPass, $newMasterPass, $hashMPass)) {
         SP\Response::printJSON(_('Errores al actualizar las claves de las cuentas del histórico'));
     }
     if (!\SP\CustomFields::updateCustomFieldsCrypt($currentMasterPass, $newMasterPass)) {
         SP\Response::printJSON(_('Errores al actualizar datos de campos personalizados'));
     }
 }
 if (SP\Util::demoIsEnabled()) {
     SP\Response::printJSON(_('Ey, esto es una DEMO!!'));