summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2016-10-24 11:36:02 +0200
committerGitHub <noreply@github.com>2016-10-24 11:36:02 +0200
commiteb47c20bdc1fb6ffd54a2fc936f77ddbbc981c35 (patch)
tree6474f6361906aae1f809b36e4d713eb32011a10f
parent5212549490501c9fa8bf29dc741d6e4e571fb52f (diff)
parente12e27fa65953e96eb3bb66981eb8b201c7a064d (diff)
downloadnextcloud-server-eb47c20bdc1fb6ffd54a2fc936f77ddbbc981c35.tar.gz
nextcloud-server-eb47c20bdc1fb6ffd54a2fc936f77ddbbc981c35.zip
Merge pull request #1770 from nextcloud/backport-1766-force-uid-casing-on-transfer-ownership-9
[stable9] Make sure the UID is correctly cased
-rw-r--r--apps/files/command/transferownership.php13
-rw-r--r--lib/private/user/manager.php10
2 files changed, 20 insertions, 3 deletions
diff --git a/apps/files/command/transferownership.php b/apps/files/command/transferownership.php
index d3994bbdf9f..96ed8fbbb84 100644
--- a/apps/files/command/transferownership.php
+++ b/apps/files/command/transferownership.php
@@ -28,6 +28,7 @@ use OC\Files\Filesystem;
use OC\Files\View;
use OCP\Files\FileInfo;
use OCP\Files\Mount\IMountManager;
+use OCP\IUser;
use OCP\IUserManager;
use OCP\Share\IManager;
use OCP\Share\IShare;
@@ -92,15 +93,21 @@ class TransferOwnership extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$this->sourceUser = $input->getArgument('source-user');
$this->destinationUser = $input->getArgument('destination-user');
- if (!$this->userManager->userExists($this->sourceUser)) {
+ $source = $this->userManager->get($this->sourceUser);
+ $destination = $this->userManager->get($this->destinationUser);
+
+ if (!$source instanceof IUser) {
$output->writeln("<error>Unknown source user $this->sourceUser</error>");
return;
}
- if (!$this->userManager->userExists($this->destinationUser)) {
+ if (!$destination instanceof IUser) {
$output->writeln("<error>Unknown destination user $this->destinationUser</error>");
return;
}
-
+
+ $this->sourceUser = $source->getUID();
+ $this->destinationUser = $destination->getUID();
+
// target user has to be ready
if (!\OC::$server->getEncryptionManager()->isReadyForUser($this->destinationUser)) {
$output->writeln("<error>The target user is not ready to accept files. The user has at least to be logged in once.</error>");
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index eb86873a26f..e638823ad29 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -155,6 +155,16 @@ class Manager extends PublicEmitter implements IUserManager {
return $this->cachedUsers[$uid];
}
+ if (method_exists($backend, 'loginName2UserName')) {
+ $loginName = $backend->loginName2UserName($uid);
+ if ($loginName !== false) {
+ $uid = $loginName;
+ }
+ if (isset($this->cachedUsers[$uid])) {
+ return $this->cachedUsers[$uid];
+ }
+ }
+
$user = new User($uid, $backend, $this, $this->config);
if ($cacheUser) {
$this->cachedUsers[$uid] = $user;