summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-07-11 22:43:47 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-08-31 23:03:16 +0200
commitefedc81c0a2f1539806854f8a73c40fc61b1e13e (patch)
treede116f0aabb11550b8c9d789f45ba581e9d59461 /apps/user_ldap
parent84ea66dca8593a967d0114a7d0206260263f61f9 (diff)
downloadnextcloud-server-efedc81c0a2f1539806854f8a73c40fc61b1e13e.tar.gz
nextcloud-server-efedc81c0a2f1539806854f8a73c40fc61b1e13e.zip
simplify returning the homePath and fixing #4117
homesToKill was not set in runtime since some changes some place else. It required deleteUser() to be called first. The method acts independent of it now. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/User/OfflineUser.php12
-rw-r--r--apps/user_ldap/lib/User_LDAP.php23
2 files changed, 12 insertions, 23 deletions
diff --git a/apps/user_ldap/lib/User/OfflineUser.php b/apps/user_ldap/lib/User/OfflineUser.php
index 0e60a29514e..942eee84cb7 100644
--- a/apps/user_ldap/lib/User/OfflineUser.php
+++ b/apps/user_ldap/lib/User/OfflineUser.php
@@ -25,6 +25,8 @@
namespace OCA\User_LDAP\User;
use OCA\User_LDAP\Mapping\UserMapping;
+use OCP\IConfig;
+use OCP\IDBConnection;
class OfflineUser {
/**
@@ -60,11 +62,11 @@ class OfflineUser {
*/
protected $hasActiveShares;
/**
- * @var \OCP\IConfig $config
+ * @var IConfig $config
*/
protected $config;
/**
- * @var \OCP\IDBConnection $db
+ * @var IDBConnection $db
*/
protected $db;
/**
@@ -74,11 +76,11 @@ class OfflineUser {
/**
* @param string $ocName
- * @param \OCP\IConfig $config
- * @param \OCP\IDBConnection $db
+ * @param IConfig $config
+ * @param IDBConnection $db
* @param \OCA\User_LDAP\Mapping\UserMapping $mapping
*/
- public function __construct($ocName, \OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) {
+ public function __construct($ocName, IConfig $config, IDBConnection $db, UserMapping $mapping) {
$this->ocName = $ocName;
$this->config = $config;
$this->db = $db;
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index 3cc2fec740e..34bcb9bb268 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -45,9 +45,6 @@ use OCP\Notification\IManager as INotificationManager;
use OCP\Util;
class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP {
- /** @var string[] $homesToKill */
- protected $homesToKill = array();
-
/** @var \OCP\IConfig */
protected $ocConfig;
@@ -359,10 +356,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
//Get Home Directory out of user preferences so we can return it later,
//necessary for removing directories as done by OC_User.
- $home = $this->ocConfig->getUserValue($uid, 'user_ldap', 'homePath', '');
- $this->homesToKill[$uid] = $home;
$this->access->getUserMapper()->unmap($uid);
-
return true;
}
@@ -375,11 +369,6 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
* @throws \Exception
*/
public function getHome($uid) {
- if(isset($this->homesToKill[$uid]) && !empty($this->homesToKill[$uid])) {
- //a deleted user who needs some clean up
- return $this->homesToKill[$uid];
- }
-
// user Exists check required as it is not done in user proxy!
if(!$this->userExists($uid)) {
return false;
@@ -391,16 +380,14 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
return $path;
}
+ // early return path if it is a deleted user
$user = $this->access->userManager->get($uid);
- if(is_null($user) || ($user instanceof OfflineUser && !$this->userExistsOnLDAP($user->getOCName()))) {
- throw new NoUserException($uid . ' is not a valid user anymore');
- }
if($user instanceof OfflineUser) {
- // apparently this user survived the userExistsOnLDAP check,
- // we request the user instance again in order to retrieve a User
- // instance instead
- $user = $this->access->userManager->get($uid);
+ return $user->getHomePath();
+ } else if ($user === null) {
+ throw new NoUserException($uid . ' is not a valid user anymore');
}
+
$path = $user->getHomePath();
$this->access->cacheUserHome($uid, $path);