[Pkg-owncloud-commits] [owncloud] 01/129: Make sure that remote shares use the correct uid casing
David Prévot
taffit at moszumanska.debian.org
Thu Nov 5 01:04:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 02493563a21802ef7f22f98a99c19e44fcc12c10
Author: Joas Schilling <nickvergessen at owncloud.com>
Date: Mon Oct 5 11:50:36 2015 +0200
Make sure that remote shares use the correct uid casing
---
apps/files_sharing/api/server2server.php | 1 +
lib/base.php | 8 ++++++++
lib/private/user/database.php | 32 ++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/apps/files_sharing/api/server2server.php b/apps/files_sharing/api/server2server.php
index a74b329..2e04680 100644
--- a/apps/files_sharing/api/server2server.php
+++ b/apps/files_sharing/api/server2server.php
@@ -53,6 +53,7 @@ class Server2Server {
return new \OC_OCS_Result(null, 400, 'The mountpoint name contains invalid characters.');
}
+ // FIXME this should be a method in the user management instead
\OCP\Util::writeLog('files_sharing', 'shareWith before, ' . $shareWith, \OCP\Util::DEBUG);
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
diff --git a/lib/base.php b/lib/base.php
index 12c23f5..5deba78 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -608,6 +608,14 @@ class OC {
OC_User::useBackend(new OC_User_Database());
OC_Group::useBackend(new OC_Group_Database());
+ // Subscribe to the hook
+ \OCP\Util::connectHook(
+ '\OCA\Files_Sharing\API\Server2Server',
+ 'preLoginNameUsedAsUserName',
+ '\OC_User_Database',
+ 'preLoginNameUsedAsUserName'
+ );
+
//setup extra user backends
if (!self::checkUpgrade(false)) {
OC_User::setupBackends();
diff --git a/lib/private/user/database.php b/lib/private/user/database.php
index 0810663..3969b44 100644
--- a/lib/private/user/database.php
+++ b/lib/private/user/database.php
@@ -295,6 +295,20 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend {
}
/**
+ * returns the username for the given login name in the correct casing
+ *
+ * @param string $loginName
+ * @return string|false
+ */
+ public function loginName2UserName($loginName) {
+ if ($this->userExists($loginName)) {
+ return $this->cache[$loginName]['uid'];
+ }
+
+ return false;
+ }
+
+ /**
* Backend name to be shown in user management
* @return string the name of the backend to be shown
*/
@@ -302,4 +316,22 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend {
return 'Database';
}
+ public static function preLoginNameUsedAsUserName($param) {
+ if(!isset($param['uid'])) {
+ throw new \Exception('key uid is expected to be set in $param');
+ }
+
+ $backends = \OC::$server->getUserManager()->getBackends();
+ foreach ($backends as $backend) {
+ if ($backend instanceof \OC_User_Database) {
+ /** @var \OC_User_Database $backend */
+ $uid = $backend->loginName2UserName($param['uid']);
+ if ($uid !== false) {
+ $param['uid'] = $uid;
+ return;
+ }
+ }
+ }
+
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list