diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2013-11-26 12:57:39 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2013-11-26 12:57:39 +0100 |
commit | 69518b901326617a2a80986df0e250038684563b (patch) | |
tree | b1ddb824744d5f667f032cbf349b0128139569d2 | |
parent | 03375d6c522035b108e4cf00239b9705b93dc377 (diff) | |
download | nextcloud-server-69518b901326617a2a80986df0e250038684563b.tar.gz nextcloud-server-69518b901326617a2a80986df0e250038684563b.zip |
Make sure Avatar is set from LDAP upon first login, not later, but also not before due to missing user folder
-rw-r--r-- | apps/user_ldap/user_ldap.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 97fc2fbb6c8..527a5c10b85 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -76,8 +76,11 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface { * @return void */ private function updateAvatar($uid, $dn) { - $lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap', 'lastJpegPhotoLookup', 0); - if((time() - $lastChecked) < 86400 ) { + $hasLoggedIn = \OCP\Config::getUserValue($uid, 'user_ldap', + 'firstLoginAccomplished', 0); + $lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap', + 'lastJpegPhotoLookup', 0); + if(($hasLoggedIn !== '1') || (time() - intval($lastChecked)) < 86400 ) { //update only once a day return; } @@ -105,6 +108,11 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface { \OCP\Util::ERROR); return; } + + if(!\OC\Files\Filesystem::$loaded) { + \OC_Util::setupFS($uid); + } + $avatarManager = \OC::$server->getAvatarManager(); $avatar = $avatarManager->getAvatar($uid); $avatar->set($image); @@ -160,6 +168,10 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface { return false; } + \OCP\Config::setUserValue($ocname, 'user_ldap', + 'firstLoginAccomplished', 1); + + $this->updateAvatar($ocname, $dn); //give back the display name return $ocname; } |