diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2016-03-16 20:51:03 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2016-03-21 22:38:18 +0100 |
commit | cf73db11b5d62239baf9736602d15a0e9f11a312 (patch) | |
tree | 745560e89a895ae7c8baac72a3c6a9f75ebc0164 | |
parent | 8ba36692bf71628274a9e32037a6ee195f484b08 (diff) | |
download | nextcloud-server-cf73db11b5d62239baf9736602d15a0e9f11a312.tar.gz nextcloud-server-cf73db11b5d62239baf9736602d15a0e9f11a312.zip |
Avatar must be saved after login is done and external storages set up properly, fixes #21555
-rw-r--r-- | apps/user_ldap/lib/user/user.php | 17 | ||||
-rw-r--r-- | apps/user_ldap/tests/user/user.php | 1 |
2 files changed, 17 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/user/user.php b/apps/user_ldap/lib/user/user.php index 083f517f9f1..4707f0d0dd2 100644 --- a/apps/user_ldap/lib/user/user.php +++ b/apps/user_ldap/lib/user/user.php @@ -207,7 +207,11 @@ class User { foreach ($attrs as $attr) { if(isset($ldapEntry[$attr])) { $this->avatarImage = $ldapEntry[$attr][0]; - $this->updateAvatar(); + // the call to the method that saves the avatar in the file + // system must be postponed after the login. It is to ensure + // external mounts are mounted properly (e.g. with login + // credentials from the session). + \OCP\Util::connectHook('OC_User', 'post_login', $this, 'updateAvatarPostLogin'); break; } } @@ -452,6 +456,17 @@ class User { } /** + * called by a post_login hook to save the avatar picture + * + * @param array $params + */ + public function updateAvatarPostLogin($params) { + if(isset($params['uid']) && $params['uid'] === $this->getUsername()) { + $this->updateAvatar(); + } + } + + /** * @brief attempts to get an image from LDAP and sets it as ownCloud avatar * @return null */ diff --git a/apps/user_ldap/tests/user/user.php b/apps/user_ldap/tests/user/user.php index 166fe4b000c..74f27877882 100644 --- a/apps/user_ldap/tests/user/user.php +++ b/apps/user_ldap/tests/user/user.php @@ -774,6 +774,7 @@ class Test_User_User extends \Test\TestCase { } $userMock->processAttributes($record); + \OC_Hook::emit('OC_User', 'post_login', array('uid' => $uid)); } public function emptyHomeFolderAttributeValueProvider() { |