]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't force displayname if backend already provides one 3507/head
authorLukas Reschke <lukas@statuscode.ch>
Thu, 16 Feb 2017 12:23:04 +0000 (13:23 +0100)
committerLukas Reschke <lukas@statuscode.ch>
Thu, 16 Feb 2017 12:55:48 +0000 (13:55 +0100)
`\OC_User::loginWithApache` is used in combination with backend mechanisms like our SSO / SAML integration. Those can optionally already provide a displayname using other means. For example by mapping SAML attributes.

The current approach makes it however impossible for backends using `\OCP\Authentication\IApacheBackend` to set a displayname on their own. Because the display name will simply be overwritten with the loginname.

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
lib/private/legacy/user.php

index 0a52be7565d102b612713b941fed863ac2df8cc5..661242a659a5672434305f2d74206ab1aa74836b 100644 (file)
@@ -187,7 +187,18 @@ class OC_User {
                if ($uid) {
                        if (self::getUser() !== $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);
                                $request = OC::$server->getRequest();
                                self::getUserSession()->createSessionToken($request, $uid, $uid);