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>
This commit is contained in:
parent
84ea66dca8
commit
efedc81c0a
2 changed files with 12 additions and 23 deletions
|
@ -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;
|
||||
|
|
|
@ -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()))) {
|
||||
if($user instanceof OfflineUser) {
|
||||
return $user->getHomePath();
|
||||
} else if ($user === null) {
|
||||
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);
|
||||
}
|
||||
|
||||
$path = $user->getHomePath();
|
||||
$this->access->cacheUserHome($uid, $path);
|
||||
|
||||
|
|
Loading…
Reference in a new issue