Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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>
  • Loading branch information
blizzz committed Aug 31, 2017
commit efedc81c0a2f1539806854f8a73c40fc61b1e13e
12 changes: 7 additions & 5 deletions apps/user_ldap/lib/User/OfflineUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
namespace OCA\User_LDAP\User;

use OCA\User_LDAP\Mapping\UserMapping;
use OCP\IConfig;
use OCP\IDBConnection;

class OfflineUser {
/**
Expand Down Expand Up @@ -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;
/**
Expand All @@ -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;
Expand Down
23 changes: 5 additions & 18 deletions apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
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;

Expand Down Expand Up @@ -359,10 +356,7 @@ public function deleteUser($uid) {

//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;
}

Expand All @@ -375,11 +369,6 @@ public function deleteUser($uid) {
* @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;
Expand All @@ -391,16 +380,14 @@ public function getHome($uid) {
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);

Expand Down