Avatar must be saved after login is done and external storages set up properly, fixes #21555

This commit is contained in:
Arthur Schiwon 2016-03-16 20:51:03 +01:00
parent da95db78d0
commit f6b6813f5f
2 changed files with 17 additions and 1 deletions

View File

@ -217,7 +217,11 @@ class User {
foreach ($attrs as $attr) { foreach ($attrs as $attr) {
if(isset($ldapEntry[$attr])) { if(isset($ldapEntry[$attr])) {
$this->avatarImage = $ldapEntry[$attr][0]; $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; break;
} }
} }
@ -461,6 +465,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 * @brief attempts to get an image from LDAP and sets it as ownCloud avatar
* @return null * @return null

View File

@ -798,6 +798,7 @@ class Test_User_User extends \Test\TestCase {
} }
$userMock->processAttributes($record); $userMock->processAttributes($record);
\OC_Hook::emit('OC_User', 'post_login', array('uid' => $uid));
} }
public function emptyHomeFolderAttributeValueProvider() { public function emptyHomeFolderAttributeValueProvider() {