Files
FreshRSS/cli/create-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

47 lines
1.3 KiB
PHP
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env php
<?php
$isUpdate = false;
require(__DIR__ . '/_update-or-create-user.php');
$username = $GLOBALS['options']['user'];
if (!FreshRSS_user_Controller::checkUsername($username)) {
fail('FreshRSS error: invalid username “' . $username .
'”! Must be matching ' . FreshRSS_user_Controller::USERNAME_PATTERN);
}
$usernames = listUsers();
if (preg_grep("/^$username$/i", $usernames) !== false) {
fail('FreshRSS warning: username already exists “' . $username . '”', EXIT_CODE_ALREADY_EXISTS);
}
echo 'FreshRSS creating user “', $username, "”…\n";
$ok = FreshRSS_user_Controller::createUser(
$username,
empty($options['mail_login']) ? '' : $options['mail_login'],
empty($options['password']) ? '' : $options['password'],
$GLOBALS['values'],
!isset($options['no_default_feeds'])
);
if (!$ok) {
fail('FreshRSS could not create user!');
}
if (!empty($options['api_password'])) {
$username = cliInitUser($username);
$error = FreshRSS_api_Controller::updatePassword($options['api_password']);
if ($error !== false) {
fail($error);
}
}
invalidateHttpCache(FreshRSS_Context::$system_conf->default_user);
echo ' Remember to refresh the feeds of the user: ', $username ,
"\t", './cli/actualize-user.php --user ', $username, "\n";
accessRights();
done($ok);