Files
FreshRSS/cli/delete-user.php
Luc SANCHEZ 7f9594b8c7 fix many "Only booleans are allowed in an if condition" (#5501)
* fix many "Only booleans are allowed in an if condition"

* Update cli/create-user.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Update cli/i18n/I18nUsageValidator.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

* Fix several regressions and other minor things

* Fix another regression

* Update lib/http-conditional.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-07-07 21:53:17 +02:00

37 lines
1.0 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
require(__DIR__ . '/_cli.php');
performRequirementCheck(FreshRSS_Context::$system_conf->db['type'] ?? '');
$params = array(
'user:',
);
$options = getopt('', $params);
if (!validateOptions($argv, $params) || empty($options['user']) || !is_string($options['user'])) {
fail('Usage: ' . basename(__FILE__) . " --user username");
}
$username = $options['user'];
if (!FreshRSS_user_Controller::checkUsername($username)) {
fail('FreshRSS error: invalid username “' . $username . '”');
}
$usernames = listUsers();
if (preg_grep("/^$username$/i", $usernames) === false) {
fail('FreshRSS error: username not found “' . $username . '”');
}
if (strcasecmp($username, FreshRSS_Context::$system_conf->default_user) === 0) {
fail('FreshRSS error: default user must not be deleted: “' . $username . '”');
}
echo 'FreshRSS deleting user “', $username, "”…\n";
$ok = FreshRSS_user_Controller::deleteUser($username);
invalidateHttpCache(FreshRSS_Context::$system_conf->default_user);
done($ok);