mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-31 08:31:03 -05:00
* Pass PHPStan level 8 And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels * Revert wrong replace in comment * Fix PHPStan level 8 * Update PHPStan and other dev dependencies * Remove obsolete comment * noVariableVariables and towards bleedingEdge https://github.com/phpstan/phpstan-strict-rules https://phpstan.org/blog/what-is-bleeding-edge * More bleedingEdge * A bit more PHPStan level 9 * More PHPStan level 9 * Prepare for booleansInConditions Ignore int and null * Revert wrong line * More fixes * Fix keep_max_n_unread * Stricter attribute functions * Stricter callHooks and more PHPStan level 9 * More typing * A tiny more
49 lines
1.3 KiB
PHP
Executable File
49 lines
1.3 KiB
PHP
Executable File
#!/usr/bin/env php
|
||
<?php
|
||
declare(strict_types=1);
|
||
|
||
$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)) {
|
||
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::systemConf()->default_user);
|
||
|
||
echo 'ℹ️ Remember to refresh the feeds of the user: ', $username ,
|
||
"\t", './cli/actualize-user.php --user ', $username, "\n";
|
||
|
||
accessRights();
|
||
|
||
done($ok);
|