Merge pull request #3507 from nextcloud/if-backend-implements-get-display-name-dont-force-one

Don't force displayname if backend already provides one
This commit is contained in:
Lukas Reschke 2017-02-16 14:20:06 +01:00 committed by GitHub
commit cdc48d301e
1 changed files with 12 additions and 1 deletions

View File

@ -187,7 +187,18 @@ class OC_User {
if ($uid) { if ($uid) {
if (self::getUser() !== $uid) { if (self::getUser() !== $uid) {
self::setUserId($uid); self::setUserId($uid);
self::setDisplayName($uid); $setUidAsDisplayName = true;
if($backend instanceof \OCP\UserInterface
&& $backend->implementsActions(OC_User_Backend::GET_DISPLAYNAME)) {
$backendDisplayName = $backend->getDisplayName($uid);
if(is_string($backendDisplayName) && trim($backendDisplayName) !== '') {
$setUidAsDisplayName = false;
}
}
if($setUidAsDisplayName) {
self::setDisplayName($uid);
}
self::getUserSession()->setLoginName($uid); self::getUserSession()->setLoginName($uid);
$request = OC::$server->getRequest(); $request = OC::$server->getRequest();
self::getUserSession()->createSessionToken($request, $uid, $uid); self::getUserSession()->createSessionToken($request, $uid, $uid);