Files
FreshRSS/cli/create-user.php
Alexandre Alapetite bb9b166eb1 Fix CLI api_password (#3179)
* Fix CLI api_password

#fix https://github.com/FreshRSS/FreshRSS/issues/3177
Fix regression from https://github.com/FreshRSS/FreshRSS/pull/2675

* Update cli/_update-or-create-user.php

Co-authored-by: oupala <oupala@users.noreply.github.com>

Co-authored-by: oupala <oupala@users.noreply.github.com>
2020-09-17 09:43:39 +02:00

47 lines
1.2 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
$isUpdate = false;
require(__DIR__ . '/_update-or-create-user.php');
$username = $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 error: username already taken “' . $username . '”');
}
echo 'FreshRSS creating user “', $username, "”…\n";
$ok = FreshRSS_user_Controller::createUser(
$username,
empty($options['mail_login']) ? '' : $options['mail_login'],
empty($options['password']) ? '' : $options['password'],
$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) {
fail($error);
}
}
invalidateHttpCache(FreshRSS_Context::$system_conf->default_user);
echo '• Remember to refresh the feeds of the user: ', $username , "\n",
"\t", './cli/actualize-user.php --user ', $username, "\n";
accessRights();
done($ok);