migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
+159
View File
@@ -0,0 +1,159 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Laurens Post <lkpost@scept.re>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Files\Filesystem;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
class Add extends Command {
public function __construct(
protected IUserManager $userManager,
protected IGroupManager $groupManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:add')
->setDescription('adds a user')
->addArgument(
'uid',
InputArgument::REQUIRED,
'User ID used to login (must only contain a-z, A-Z, 0-9, -, _ and @)'
)
->addOption(
'password-from-env',
null,
InputOption::VALUE_NONE,
'read password from environment variable OC_PASS'
)
->addOption(
'display-name',
null,
InputOption::VALUE_OPTIONAL,
'User name used in the web UI (can contain any characters)'
)
->addOption(
'group',
'g',
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
'groups the user should be added to (The group will be created if it does not exist)'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$uid = $input->getArgument('uid');
if ($this->userManager->userExists($uid)) {
$output->writeln('<error>The user "' . $uid . '" already exists.</error>');
return 1;
}
if ($input->getOption('password-from-env')) {
$password = getenv('OC_PASS');
if (!$password) {
$output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>');
return 1;
}
} elseif ($input->isInteractive()) {
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$question = new Question('Enter password: ');
$question->setHidden(true);
$password = $helper->ask($input, $output, $question);
$question = new Question('Confirm password: ');
$question->setHidden(true);
$confirm = $helper->ask($input, $output, $question);
if ($password !== $confirm) {
$output->writeln("<error>Passwords did not match!</error>");
return 1;
}
} else {
$output->writeln("<error>Interactive input or --password-from-env is needed for entering a password!</error>");
return 1;
}
try {
$user = $this->userManager->createUser(
$input->getArgument('uid'),
$password
);
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
}
if ($user instanceof IUser) {
$output->writeln('<info>The user "' . $user->getUID() . '" was created successfully</info>');
} else {
$output->writeln('<error>An error occurred while creating the user</error>');
return 1;
}
if ($input->getOption('display-name')) {
$user->setDisplayName($input->getOption('display-name'));
$output->writeln('Display name set to "' . $user->getDisplayName() . '"');
}
$groups = $input->getOption('group');
if (!empty($groups)) {
// Make sure we init the Filesystem for the user, in case we need to
// init some group shares.
Filesystem::init($user->getUID(), '');
}
foreach ($groups as $groupName) {
$group = $this->groupManager->get($groupName);
if (!$group) {
$this->groupManager->createGroup($groupName);
$group = $this->groupManager->get($groupName);
if ($group instanceof IGroup) {
$output->writeln('Created group "' . $group->getGID() . '"');
}
}
if ($group instanceof IGroup) {
$group->addUser($user);
$output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
}
}
return 0;
}
}
@@ -0,0 +1,122 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, NextCloud, Inc.
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
* @author Sean Molenaar <sean@seanmolenaar.eu>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Core\Command\User\AuthTokens;
use OC\Authentication\Events\AppPasswordCreatedEvent;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
class Add extends Command {
public function __construct(
protected IUserManager $userManager,
protected IProvider $tokenProvider,
private ISecureRandom $random,
private IEventDispatcher $eventDispatcher,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:auth-tokens:add')
->setAliases(['user:add-app-password'])
->setDescription('Add app password for the named user')
->addArgument(
'user',
InputArgument::REQUIRED,
'Username to add app password for'
)
->addOption(
'password-from-env',
null,
InputOption::VALUE_NONE,
'Read password from environment variable NC_PASS/OC_PASS. Alternatively it will be asked for interactively or an app password without the login password will be created.'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$username = $input->getArgument('user');
$password = null;
$user = $this->userManager->get($username);
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
return 1;
}
if ($input->getOption('password-from-env')) {
$password = getenv('NC_PASS') ?? getenv('OC_PASS');
if (!$password) {
$output->writeln('<error>--password-from-env given, but NC_PASS is empty!</error>');
return 1;
}
} elseif ($input->isInteractive()) {
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$question = new Question('Enter the user password: ');
$question->setHidden(true);
/** @var null|string $password */
$password = $helper->ask($input, $output, $question);
}
if ($password === null) {
$output->writeln('<info>No password provided. The generated app password will therefore have limited capabilities. Any operation that requires the login password will fail.</info>');
}
$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
$generatedToken = $this->tokenProvider->generateToken(
$token,
$user->getUID(),
$user->getUID(),
$password,
'cli',
IToken::PERMANENT_TOKEN,
IToken::DO_NOT_REMEMBER
);
$this->eventDispatcher->dispatchTyped(
new AppPasswordCreatedEvent($generatedToken)
);
$output->writeln('app password:');
$output->writeln($token);
return 0;
}
}
@@ -0,0 +1,120 @@
<?php
/**
* @copyright Copyright (c) 2023 Lucas Azevedo <lhs_azevedo@hotmail.com>
*
* @author Lucas Azevedo <lhs_azevedo@hotmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Core\Command\User\AuthTokens;
use DateTimeImmutable;
use OC\Authentication\Token\IProvider;
use OC\Core\Command\Base;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Delete extends Base {
public function __construct(
protected IProvider $tokenProvider,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('user:auth-tokens:delete')
->setDescription('Deletes an authentication token')
->addArgument(
'uid',
InputArgument::REQUIRED,
'ID of the user to delete tokens for'
)
->addArgument(
'id',
InputArgument::OPTIONAL,
'ID of the auth token to delete'
)
->addOption(
'last-used-before',
null,
InputOption::VALUE_REQUIRED,
'Delete tokens last used before a given date.'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$uid = $input->getArgument('uid');
$id = (int) $input->getArgument('id');
$before = $input->getOption('last-used-before');
if ($before) {
if ($id) {
throw new RuntimeException('Option --last-used-before cannot be used with [<id>]');
}
return $this->deleteLastUsedBefore($uid, $before);
}
if (!$id) {
throw new RuntimeException('Not enough arguments. Specify the token <id> or use the --last-used-before option.');
}
return $this->deleteById($uid, $id);
}
protected function deleteById(string $uid, int $id): int {
$this->tokenProvider->invalidateTokenById($uid, $id);
return Command::SUCCESS;
}
protected function deleteLastUsedBefore(string $uid, string $before): int {
$date = $this->parseDateOption($before);
if (!$date) {
throw new RuntimeException('Invalid date format. Acceptable formats are: ISO8601 (w/o fractions), "YYYY-MM-DD" and Unix time in seconds.');
}
$this->tokenProvider->invalidateLastUsedBefore($uid, $date->getTimestamp());
return Command::SUCCESS;
}
/**
* @return \DateTimeImmutable|false
*/
protected function parseDateOption(string $input) {
$date = false;
// Handle Unix timestamp
if (filter_var($input, FILTER_VALIDATE_INT)) {
return new DateTimeImmutable('@' . $input);
}
// ISO8601
$date = DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, $input);
if ($date) {
return $date;
}
// YYYY-MM-DD
return DateTimeImmutable::createFromFormat('!Y-m-d', $input);
}
}
@@ -0,0 +1,100 @@
<?php
/**
* @copyright Copyright (c) 2023 Lucas Azevedo <lhs_azevedo@hotmail.com>
*
* @author Lucas Azevedo <lhs_azevedo@hotmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Core\Command\User\AuthTokens;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
use OC\Core\Command\Base;
use OCP\IUserManager;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ListCommand extends Base {
public function __construct(
protected IUserManager $userManager,
protected IProvider $tokenProvider,
) {
parent::__construct();
}
protected function configure(): void {
parent::configure();
$this
->setName('user:auth-tokens:list')
->setDescription('List authentication tokens of an user')
->addArgument(
'user',
InputArgument::REQUIRED,
'User to list auth tokens for'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('user'));
if (is_null($user)) {
$output->writeln('<error>user not found</error>');
return 1;
}
$tokens = $this->tokenProvider->getTokenByUser($user->getUID());
$tokens = array_map(function (IToken $token) use ($input): mixed {
$sensitive = [
'password',
'password_hash',
'token',
'public_key',
'private_key',
];
$data = array_diff_key($token->jsonSerialize(), array_flip($sensitive));
if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
$data = $this->formatTokenForPlainOutput($data);
}
return $data;
}, $tokens);
$this->writeTableInOutputFormat($input, $output, $tokens);
return 0;
}
public function formatTokenForPlainOutput(array $token): array {
$token['scope'] = implode(', ', array_keys(array_filter($token['scope'] ?? [])));
$token['lastActivity'] = date(DATE_ATOM, $token['lastActivity']);
$token['type'] = match ($token['type']) {
IToken::TEMPORARY_TOKEN => 'temporary',
IToken::PERMANENT_TOKEN => 'permanent',
IToken::WIPE_TOKEN => 'wipe',
default => $token['type'],
};
return $token;
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Jens-Christian Fischer <jens-christian.fischer@switch.ch>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Delete extends Base {
public function __construct(
protected IUserManager $userManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:delete')
->setDescription('deletes the specified user')
->addArgument(
'uid',
InputArgument::REQUIRED,
'the username'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
return 0;
}
if ($user->delete()) {
$output->writeln('<info>The specified user was deleted</info>');
return 0;
}
$output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>');
return 1;
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'uid') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
}
return [];
}
}
@@ -0,0 +1,81 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Disable extends Base {
public function __construct(
protected IUserManager $userManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:disable')
->setDescription('disables the specified user')
->addArgument(
'uid',
InputArgument::REQUIRED,
'the username'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
return 1;
}
$user->setEnabled(false);
$output->writeln('<info>The specified user is disabled</info>');
return 0;
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'uid') {
return array_map(
static fn (IUser $user) => $user->getUID(),
array_filter(
$this->userManager->search($context->getCurrentWord()),
static fn (IUser $user) => $user->isEnabled()
)
);
}
return [];
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Enable extends Base {
public function __construct(
protected IUserManager $userManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:enable')
->setDescription('enables the specified user')
->addArgument(
'uid',
InputArgument::REQUIRED,
'the username'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
return 1;
}
$user->setEnabled(true);
$output->writeln('<info>The specified user is enabled</info>');
return 0;
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'uid') {
return array_map(
static fn (IUser $user) => $user->getUID(),
array_filter(
$this->userManager->search($context->getCurrentWord()),
static fn (IUser $user) => !$user->isEnabled()
)
);
}
return [];
}
}
+118
View File
@@ -0,0 +1,118 @@
<?php
/**
* @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Info extends Base {
public function __construct(
protected IUserManager $userManager,
protected IGroupManager $groupManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:info')
->setDescription('show user info')
->addArgument(
'user',
InputArgument::REQUIRED,
'user to show'
)->addOption(
'output',
null,
InputOption::VALUE_OPTIONAL,
'Output format (plain, json or json_pretty, default is plain)',
$this->defaultOutputFormat
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('user'));
if (is_null($user)) {
$output->writeln('<error>user not found</error>');
return 1;
}
$groups = $this->groupManager->getUserGroupIds($user);
$data = [
'user_id' => $user->getUID(),
'display_name' => $user->getDisplayName(),
'email' => (string)$user->getSystemEMailAddress(),
'cloud_id' => $user->getCloudId(),
'enabled' => $user->isEnabled(),
'groups' => $groups,
'quota' => $user->getQuota(),
'storage' => $this->getStorageInfo($user),
'last_seen' => date(\DateTimeInterface::ATOM, $user->getLastLogin()), // ISO-8601
'user_directory' => $user->getHome(),
'backend' => $user->getBackendClassName()
];
$this->writeArrayInOutputFormat($input, $output, $data);
return 0;
}
/**
* @param IUser $user
* @return array
*/
protected function getStorageInfo(IUser $user): array {
\OC_Util::tearDownFS();
\OC_Util::setupFS($user->getUID());
try {
$storage = \OC_Helper::getStorageInfo('/');
} catch (\OCP\Files\NotFoundException $e) {
return [];
}
return [
'free' => $storage['free'],
'used' => $storage['used'],
'total' => $storage['total'],
'relative' => $storage['relative'],
'quota' => $storage['quota'],
];
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'user') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
}
return [];
}
}
@@ -0,0 +1,85 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Pierre Ozoux <pierre@ozoux.net>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class LastSeen extends Base {
public function __construct(
protected IUserManager $userManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:lastseen')
->setDescription('shows when the user was logged in last time')
->addArgument(
'uid',
InputArgument::REQUIRED,
'the username'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $this->userManager->get($input->getArgument('uid'));
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
return 1;
}
$lastLogin = $user->getLastLogin();
if ($lastLogin === 0) {
$output->writeln('User ' . $user->getUID() .
' has never logged in, yet.');
} else {
$date = new \DateTime();
$date->setTimestamp($lastLogin);
$output->writeln($user->getUID() .
'`s last login: ' . $date->format('d.m.Y H:i'));
}
return 0;
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'uid') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
}
return [];
}
}
@@ -0,0 +1,110 @@
<?php
/**
* @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
*
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ListCommand extends Base {
public function __construct(
protected IUserManager $userManager,
protected IGroupManager $groupManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:list')
->setDescription('list configured users')
->addOption(
'limit',
'l',
InputOption::VALUE_OPTIONAL,
'Number of users to retrieve',
'500'
)->addOption(
'offset',
'o',
InputOption::VALUE_OPTIONAL,
'Offset for retrieving users',
'0'
)->addOption(
'output',
null,
InputOption::VALUE_OPTIONAL,
'Output format (plain, json or json_pretty, default is plain)',
$this->defaultOutputFormat
)->addOption(
'info',
'i',
InputOption::VALUE_NONE,
'Show detailed info'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$users = $this->userManager->searchDisplayName('', (int) $input->getOption('limit'), (int) $input->getOption('offset'));
$this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users, (bool)$input->getOption('info')));
return 0;
}
/**
* @param IUser[] $users
* @param bool [$detailed=false]
* @return array
*/
private function formatUsers(array $users, bool $detailed = false) {
$keys = array_map(function (IUser $user) {
return $user->getUID();
}, $users);
$values = array_map(function (IUser $user) use ($detailed) {
if ($detailed) {
$groups = $this->groupManager->getUserGroupIds($user);
return [
'user_id' => $user->getUID(),
'display_name' => $user->getDisplayName(),
'email' => (string)$user->getSystemEMailAddress(),
'cloud_id' => $user->getCloudId(),
'enabled' => $user->isEnabled(),
'groups' => $groups,
'quota' => $user->getQuota(),
'last_seen' => date(\DateTimeInterface::ATOM, $user->getLastLogin()), // ISO-8601
'user_directory' => $user->getHome(),
'backend' => $user->getBackendClassName()
];
}
return $user->getDisplayName();
}, $users);
return array_combine($keys, $values);
}
}
+109
View File
@@ -0,0 +1,109 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Files\View;
use OCP\IConfig;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Report extends Command {
public const DEFAULT_COUNT_DIRS_MAX_USERS = 500;
public function __construct(
protected IUserManager $userManager,
private IConfig $config,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('user:report')
->setDescription('shows how many users have access')
->addOption(
'count-dirs',
null,
InputOption::VALUE_NONE,
'Also count the number of user directories in the database (could time out on huge installations, therefore defaults to no with ' . self::DEFAULT_COUNT_DIRS_MAX_USERS . '+ users)'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$table = new Table($output);
$table->setHeaders(['User Report', '']);
$userCountArray = $this->countUsers();
$total = 0;
if (!empty($userCountArray)) {
$rows = [];
foreach ($userCountArray as $classname => $users) {
$total += $users;
$rows[] = [$classname, $users];
}
$rows[] = [' '];
$rows[] = ['total users', $total];
} else {
$rows[] = ['No backend enabled that supports user counting', ''];
}
$rows[] = [' '];
if ($total <= self::DEFAULT_COUNT_DIRS_MAX_USERS || $input->getOption('count-dirs')) {
$userDirectoryCount = $this->countUserDirectories();
$rows[] = ['user directories', $userDirectoryCount];
}
$activeUsers = $this->userManager->countSeenUsers();
$rows[] = ['active users', $activeUsers];
$disabledUsers = $this->config->getUsersForUserValue('core', 'enabled', 'false');
$disabledUsersCount = count($disabledUsers);
$rows[] = ['disabled users', $disabledUsersCount];
$table->setRows($rows);
$table->render();
return 0;
}
private function countUsers(): array {
return $this->userManager->countUsers();
}
private function countUserDirectories(): int {
$dataview = new View('/');
$userDirectories = $dataview->getDirectoryContent('/', 'httpd/unix-directory');
return count($userDirectories);
}
}
@@ -0,0 +1,149 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Andreas Fischer <bantu@owncloud.com>
* @author Christopher Schäpers <kondou@ts.unde.re>
* @author Clark Tomlinson <fallen013@gmail.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Laurens Post <lkpost@scept.re>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Sujith H <sharidasan@owncloud.com>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\App\IAppManager;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
class ResetPassword extends Base {
public function __construct(
protected IUserManager $userManager,
private IAppManager $appManager,
) {
parent::__construct();
}
protected function configure() {
$this
->setName('user:resetpassword')
->setDescription('Resets the password of the named user')
->addArgument(
'user',
InputArgument::REQUIRED,
'Username to reset password'
)
->addOption(
'password-from-env',
null,
InputOption::VALUE_NONE,
'read password from environment variable OC_PASS'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$username = $input->getArgument('user');
$user = $this->userManager->get($username);
if (is_null($user)) {
$output->writeln('<error>User does not exist</error>');
return 1;
}
if ($input->getOption('password-from-env')) {
$password = getenv('OC_PASS');
if (!$password) {
$output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>');
return 1;
}
} elseif ($input->isInteractive()) {
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if ($this->appManager->isEnabledForUser('encryption', $user)) {
$output->writeln(
'<error>Warning: Resetting the password when using encryption will result in data loss!</error>'
);
$question = new ConfirmationQuestion('Do you want to continue?');
if (!$helper->ask($input, $output, $question)) {
return 1;
}
}
$question = new Question('Enter a new password: ');
$question->setHidden(true);
$password = $helper->ask($input, $output, $question);
if ($password === null) {
$output->writeln("<error>Password cannot be empty!</error>");
return 1;
}
$question = new Question('Confirm the new password: ');
$question->setHidden(true);
$confirm = $helper->ask($input, $output, $question);
if ($password !== $confirm) {
$output->writeln("<error>Passwords did not match!</error>");
return 1;
}
} else {
$output->writeln("<error>Interactive input or --password-from-env is needed for entering a new password!</error>");
return 1;
}
try {
$success = $user->setPassword($password);
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
}
if ($success) {
$output->writeln("<info>Successfully reset password for " . $username . "</info>");
} else {
$output->writeln("<error>Error while resetting password!</error>");
return 1;
}
return 0;
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'user') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
}
return [];
}
}
+278
View File
@@ -0,0 +1,278 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Johannes Leuker <j.leuker@hosting.de>
* @author Kim Brose <kim.brose@rwth-aachen.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Setting extends Base {
public function __construct(
protected IUserManager $userManager,
protected IConfig $config,
) {
parent::__construct();
}
protected function configure() {
parent::configure();
$this
->setName('user:setting')
->setDescription('Read and modify user settings')
->addArgument(
'uid',
InputArgument::REQUIRED,
'User ID used to login'
)
->addArgument(
'app',
InputArgument::OPTIONAL,
'Restrict the settings to a given app',
''
)
->addArgument(
'key',
InputArgument::OPTIONAL,
'Setting key to set, get or delete',
''
)
->addOption(
'ignore-missing-user',
null,
InputOption::VALUE_NONE,
'Use this option to ignore errors when the user does not exist'
)
// Get
->addOption(
'default-value',
null,
InputOption::VALUE_REQUIRED,
'(Only applicable on get) If no default value is set and the config does not exist, the command will exit with 1'
)
// Set
->addArgument(
'value',
InputArgument::OPTIONAL,
'The new value of the setting',
null
)
->addOption(
'update-only',
null,
InputOption::VALUE_NONE,
'Only updates the value, if it is not set before, it is not being added'
)
// Delete
->addOption(
'delete',
null,
InputOption::VALUE_NONE,
'Specify this option to delete the config'
)
->addOption(
'error-if-not-exists',
null,
InputOption::VALUE_NONE,
'Checks whether the setting exists before deleting it'
)
;
}
protected function checkInput(InputInterface $input) {
if (!$input->getOption('ignore-missing-user')) {
$uid = $input->getArgument('uid');
$user = $this->userManager->get($uid);
if (!$user) {
throw new \InvalidArgumentException('The user "' . $uid . '" does not exist.');
}
// normalize uid
$input->setArgument('uid', $user->getUID());
}
if ($input->getArgument('key') === '' && $input->hasParameterOption('--default-value')) {
throw new \InvalidArgumentException('The "default-value" option can only be used when specifying a key.');
}
if ($input->getArgument('key') === '' && $input->getArgument('value') !== null) {
throw new \InvalidArgumentException('The value argument can only be used when specifying a key.');
}
if ($input->getArgument('value') !== null && $input->hasParameterOption('--default-value')) {
throw new \InvalidArgumentException('The value argument can not be used together with "default-value".');
}
if ($input->getOption('update-only') && $input->getArgument('value') === null) {
throw new \InvalidArgumentException('The "update-only" option can only be used together with "value".');
}
if ($input->getArgument('key') === '' && $input->getOption('delete')) {
throw new \InvalidArgumentException('The "delete" option can only be used when specifying a key.');
}
if ($input->getOption('delete') && $input->hasParameterOption('--default-value')) {
throw new \InvalidArgumentException('The "delete" option can not be used together with "default-value".');
}
if ($input->getOption('delete') && $input->getArgument('value') !== null) {
throw new \InvalidArgumentException('The "delete" option can not be used together with "value".');
}
if ($input->getOption('error-if-not-exists') && !$input->getOption('delete')) {
throw new \InvalidArgumentException('The "error-if-not-exists" option can only be used together with "delete".');
}
}
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$this->checkInput($input);
} catch (\InvalidArgumentException $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
}
$uid = $input->getArgument('uid');
$app = $input->getArgument('app');
$key = $input->getArgument('key');
if ($key !== '') {
$value = $this->config->getUserValue($uid, $app, $key, null);
if ($input->getArgument('value') !== null) {
if ($input->hasParameterOption('--update-only') && $value === null) {
$output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
return 1;
}
if ($app === 'settings' && in_array($key, ['email', 'display_name'])) {
$user = $this->userManager->get($uid);
if ($user instanceof IUser) {
if ($key === 'email') {
$user->setEMailAddress($input->getArgument('value'));
} elseif ($key === 'display_name') {
if (!$user->setDisplayName($input->getArgument('value'))) {
if ($user->getDisplayName() === $input->getArgument('value')) {
$output->writeln('<error>New and old display name are the same</error>');
} elseif ($input->getArgument('value') === '') {
$output->writeln('<error>New display name can\'t be empty</error>');
} else {
$output->writeln('<error>Could not set display name</error>');
}
return 1;
}
}
// setEmailAddress and setDisplayName both internally set the value
return 0;
}
}
$this->config->setUserValue($uid, $app, $key, $input->getArgument('value'));
return 0;
} elseif ($input->hasParameterOption('--delete')) {
if ($input->hasParameterOption('--error-if-not-exists') && $value === null) {
$output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
return 1;
}
if ($app === 'settings' && in_array($key, ['email', 'display_name'])) {
$user = $this->userManager->get($uid);
if ($user instanceof IUser) {
if ($key === 'email') {
$user->setEMailAddress('');
// setEmailAddress already deletes the value
return 0;
} elseif ($key === 'display_name') {
$output->writeln('<error>Display name can\'t be deleted.</error>');
return 1;
}
}
}
$this->config->deleteUserValue($uid, $app, $key);
return 0;
} elseif ($value !== null) {
$output->writeln($value);
return 0;
} elseif ($input->hasParameterOption('--default-value')) {
$output->writeln($input->getOption('default-value'));
return 0;
} else {
if ($app === 'settings' && $key === 'display_name') {
$user = $this->userManager->get($uid);
$output->writeln($user->getDisplayName());
return 0;
}
$output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>');
return 1;
}
} else {
$settings = $this->getUserSettings($uid, $app);
$this->writeArrayInOutputFormat($input, $output, $settings);
return 0;
}
}
protected function getUserSettings($uid, $app) {
$settings = $this->config->getAllUserValues($uid);
if ($app !== '') {
if (isset($settings[$app])) {
$settings = [$app => $settings[$app]];
} else {
$settings = [];
}
}
$user = $this->userManager->get($uid);
$settings['settings']['display_name'] = $user->getDisplayName();
return $settings;
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'uid') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
}
if ($argumentName === 'app') {
$userId = $context->getWordAtIndex($context->getWordIndex() - 1);
$settings = $this->getUserSettings($userId, '');
return array_keys($settings);
}
if ($argumentName === 'key') {
$userId = $context->getWordAtIndex($context->getWordIndex() - 2);
$app = $context->getWordAtIndex($context->getWordIndex() - 1);
$settings = $this->getUserSettings($userId, $app);
return array_keys($settings[$app]);
}
return [];
}
}
@@ -0,0 +1,105 @@
<?php
/**
* @copyright Copyright (c) 2023 Julius Härrtl <jus@bitgrid.net>
*
* @author Julius Härrtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\IUser;
use OCP\IUserManager;
use OCP\User\Backend\IGetDisplayNameBackend;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class SyncAccountDataCommand extends Base {
protected IUserManager $userManager;
protected IAccountManager $accountManager;
public function __construct(
IUserManager $userManager,
IAccountManager $accountManager
) {
$this->userManager = $userManager;
$this->accountManager = $accountManager;
parent::__construct();
}
protected function configure() {
$this
->setName('user:sync-account-data')
->setDescription('sync user backend data to accounts table for configured users')
->addOption(
'limit',
'l',
InputOption::VALUE_OPTIONAL,
'Number of users to retrieve',
'500'
)->addOption(
'offset',
'o',
InputOption::VALUE_OPTIONAL,
'Offset for retrieving users',
'0'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$users = $this->userManager->searchDisplayName('', (int) $input->getOption('limit'), (int) $input->getOption('offset'));
foreach ($users as $user) {
$this->updateUserAccount($user, $output);
}
return 0;
}
private function updateUserAccount(IUser $user, OutputInterface $output): void {
$changed = false;
$account = $this->accountManager->getAccount($user);
if ($user->getBackend() instanceof IGetDisplayNameBackend) {
try {
$displayNameProperty = $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
} catch (PropertyDoesNotExistException) {
$displayNameProperty = null;
}
if (!$displayNameProperty || $displayNameProperty->getValue() !== $user->getDisplayName()) {
$output->writeln($user->getUID() . ' - updating changed display name');
$account->setProperty(
IAccountManager::PROPERTY_DISPLAYNAME,
$user->getDisplayName(),
$displayNameProperty ? $displayNameProperty->getScope() : IAccountManager::SCOPE_PRIVATE,
$displayNameProperty ? $displayNameProperty->getVerified() : IAccountManager::NOT_VERIFIED,
$displayNameProperty ? $displayNameProperty->getVerificationData() : ''
);
$changed = true;
}
}
if ($changed) {
$this->accountManager->updateAccount($account);
$output->writeln($user->getUID() . ' - account data updated');
} else {
$output->writeln($user->getUID() . ' - nothing to update');
}
}
}