$Log->addDescription(sprintf('%s: %s', _('Usuario'), $userLogin)); $Log->writeLog(); SP\Response::printJSON(_('Usuario deshabilitado')); } // Obtenemos los datos del usuario if (!$User->getUserInfo()) { $Log->addDescription(_('Error al obtener los datos del usuario de la BBDD')); $Log->writeLog(); SP\Response::printJSON(_('Error interno')); } // Comprobamos que la clave maestra del usuario es correcta y está actualizada if (!$masterPass && (!UserPass::checkUserMPass($User) || !UserPass::checkUserUpdateMPass($userLogin))) { SP\Response::printJSON(_('La clave maestra no ha sido guardada o es incorrecta'), 3); } elseif ($masterPass) { if (CryptMasterPass::checkTempMasterPass($masterPass)) { $masterPass = CryptMasterPass::getTempMasterPass($masterPass); } if (!$User->updateUserMPass($masterPass)) { $Log->addDescription(_('Clave maestra incorrecta')); $Log->writeLog(); SP\Response::printJSON(_('Clave maestra incorrecta'), 4); } } // Comprobar si se ha forzado un cambio de clave if ($User->isUserChangePass()) { $hash = SP\Util::generate_random_bytes(); if (UserPassRecover::addPassRecover($userLogin, $hash)) { $url = SP\Init::$WEBURI . '/index.php?a=passreset&h=' . $hash . '&t=' . time() . '&f=1'; SP\Response::printJSON($url, 0); } }
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!!')); } // ConfigDB::readConfig(); ConfigDB::setCacheConfigValue('masterPwd', $hashMPass); ConfigDB::setCacheConfigValue('lastupdatempass', time()); if (ConfigDB::writeConfig()) { SP\Log::writeNewLogAndEmail(_('Actualizar Clave Maestra')); SP\Response::printJSON(_('Clave maestra actualizada'), 0); } else { SP\Response::printJSON(_('Error al guardar el hash de la clave maestra')); } } elseif ($actionId === SP\Controller\ActionsInterface::ACTION_CFG_ENCRYPTION_TEMPPASS) { $tempMasterMaxTime = SP\Request::analyze('tmpass_maxtime', 3600); $tempMasterPass = CryptMasterPass::setTempMasterPass($tempMasterMaxTime); if ($tempMasterPass !== false && !empty($tempMasterPass)) { SP\Email::sendEmail(new \SP\Log(_('Generar Clave Temporal'), SP\Html::strongText(_('Clave') . ': ') . $tempMasterPass)); SP\Response::printJSON(_('Clave Temporal Generada'), 0, $doActionOnClose); } else { SP\Response::printJSON(_('Error al generar clave temporal')); } } else { SP\Response::printJSON(_('Acción Inválida')); }