summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-21 09:47:50 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-21 09:47:50 +0100
commit8442516e1067a7132f52b10b24d436909fb9f7f7 (patch)
tree495f05ee09d29f2726e5b8b78a9ae07ad4dd6992
parent16782484b9d75bac38cacce25e407d917d442af4 (diff)
parentd8621c78ede66a0b72aa42f49e0fe19c32793d4f (diff)
downloadnextcloud-server-8442516e1067a7132f52b10b24d436909fb9f7f7.tar.gz
nextcloud-server-8442516e1067a7132f52b10b24d436909fb9f7f7.zip
Merge pull request #23329 from owncloud/fix-21555
Avatar must be saved after login is done and external storages set up…
-rw-r--r--apps/user_ldap/lib/user/user.php17
-rw-r--r--apps/user_ldap/tests/user/user.php1
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 43ff6014c9f..9bf505c5c22 100644
--- a/apps/user_ldap/lib/user/user.php
+++ b/apps/user_ldap/lib/user/user.php
@@ -217,7 +217,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;
}
}
@@ -462,6 +466,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 ca8d81a4b79..ed04520aa74 100644
--- a/apps/user_ldap/tests/user/user.php
+++ b/apps/user_ldap/tests/user/user.php
@@ -798,6 +798,7 @@ class Test_User_User extends \Test\TestCase {
}
$userMock->processAttributes($record);
+ \OC_Hook::emit('OC_User', 'post_login', array('uid' => $uid));
}
public function emptyHomeFolderAttributeValueProvider() {