Пример #1
0
        }
    } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_USERS_EDITPASS) {
        if (SP\Util::demoIsEnabled() && UserUtil::getUserLoginById($itemId) == 'demo') {
            SP\Response::printJSON(_('Ey, esto es una DEMO!!'));
        } elseif (!$User->getUserPass() || !$userPassR) {
            SP\Response::printJSON(_('La clave no puede estar en blanco'), 2);
        } elseif ($User->getUserPass() != $userPassR) {
            SP\Response::printJSON(_('Las claves no coinciden'), 2);
        }
        if ($User->updateUserPass()) {
            SP\Response::printJSON(_('Clave actualizada'), 0);
        }
        SP\Response::printJSON(_('Error al modificar la clave'));
        // Eliminar usuario
    } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_USERS_DELETE) {
        if (SP\Util::demoIsEnabled() && UserUtil::getUserLoginById($itemId) == 'demo') {
            SP\Response::printJSON(_('Ey, esto es una DEMO!!'));
        } elseif ($User->getUserId() == SP\Session::getUserId()) {
            SP\Response::printJSON(_('No es posible eliminar, usuario en uso'));
        }
        if ($User->deleteUser() && SP\CustomFields::deleteCustomFieldForItem($User->getUserId(), \SP\Controller\ActionsInterface::ACTION_USR_USERS)) {
            SP\Response::printJSON(_('Usuario eliminado'), 0, $doActionOnClose);
        }
        SP\Response::printJSON(_('Error al eliminar el usuario'));
    }
} elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_GROUPS_NEW || $actionId === \SP\Controller\ActionsInterface::ACTION_USR_GROUPS_EDIT || $actionId === \SP\Controller\ActionsInterface::ACTION_USR_GROUPS_DELETE) {
    // Variables POST del formulario
    $frmGrpName = SP\Request::analyze('name');
    $frmGrpDesc = SP\Request::analyze('description');
    $frmGrpUsers = SP\Request::analyze('users');
    if ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_GROUPS_NEW || $actionId === \SP\Controller\ActionsInterface::ACTION_USR_GROUPS_EDIT) {
Пример #2
0
 * 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/>.
 *
 */
use SP\Request;
use SP\SessionUtil;
define('APP_ROOT', '..');
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
Request::checkReferer('POST');
if (!SP\Init::isLoggedIn()) {
    SP\Response::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10);
}
if (SP\Util::demoIsEnabled()) {
    SP\Response::printJSON(_('Ey, esto es una DEMO!!'));
}
$sk = SP\Request::analyze('sk', false);
$defaultUser = SP\Request::analyze('defUser', 0);
$defaultGroup = SP\Request::analyze('defGroup', 0);
$importPwd = SP\Request::analyzeEncrypted('importPwd');
$csvDelimiter = SP\Request::analyze('csvDelimiter');
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
    SP\Response::printJSON(_('CONSULTA INVÁLIDA'));
}
SP\Import::setDefUser($defaultUser);
SP\Import::setDefGroup($defaultGroup);
SP\Import::setImportPwd($importPwd);
SP\Import::setCsvDelimiter($csvDelimiter);
$res = SP\Import::doImport($_FILES["inFile"]);
Пример #3
0
    $UserPrefs->setSortViews($sortViews);
    $UserPrefs->setTopNavbar($topNavbar);
    $UserPrefs->setOptionalActions($optionalActions);
    if (!$UserPrefs->updatePreferences()) {
        SP\Response::printJSON(_('Error al actualizar preferencias'));
    }
    // Forzar la detección del lenguaje tras actualizar
    SP\Language::setLanguage(true);
    SP\Themes::setTheme(true);
    // Actualizar las preferencias en la sesión y recargar la página
    SP\Session::setUserPreferences($UserPrefs);
    SP\Util::reload();
    SP\Response::printJSON(_('Preferencias actualizadas'), 0, $doActionOnClose);
} else {
    if ($actionId === SP\Controller\ActionsInterface::ACTION_USR_PREFERENCES_SECURITY) {
        if (SP\Util::demoIsEnabled() && \SP\Session::getUserLogin() === 'demo') {
            SP\Response::printJSON(_('Ey, esto es una DEMO!!'));
        }
        // Variables POST del formulario
        $twoFaEnabled = SP\Request::analyze('security_2faenabled', 0, false, 1);
        $pin = SP\Request::analyze('security_pin', 0);
        $userLogin = UserUtil::getUserLoginById($itemId);
        $twoFa = new \SP\Auth\Auth2FA($itemId, $userLogin);
        if (!$twoFa->verifyKey($pin)) {
            SP\Response::printJSON(_('Código incorrecto'));
        }
        // No se instancia la clase ya que es necesario guardar los atributos ya guardados
        $UserPrefs = \SP\UserPreferences::getPreferences($itemId);
        $UserPrefs->setId($itemId);
        $UserPrefs->setUse2Fa(\SP\Util::boolval($twoFaEnabled));
        if (!$UserPrefs->updatePreferences()) {