diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-02-16 13:23:04 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2017-02-16 13:55:48 +0100 |
commit | 92c74d2f9a4e916d1ea861c6959c8807e9944b46 (patch) | |
tree | 7fd2671bf2eb5c7d44c28d6134bc71c5223dfede /lib/private/legacy/user.php | |
parent | f25c89461c986b31171270e2186d000030b8df2e (diff) | |
download | nextcloud-server-92c74d2f9a4e916d1ea861c6959c8807e9944b46.tar.gz nextcloud-server-92c74d2f9a4e916d1ea861c6959c8807e9944b46.zip |
Don't force displayname if backend already provides one
`\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>
Diffstat (limited to 'lib/private/legacy/user.php')
-rw-r--r-- | lib/private/legacy/user.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php index 0a52be7565d..661242a659a 100644 --- a/lib/private/legacy/user.php +++ b/lib/private/legacy/user.php @@ -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); |