diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/TemplateLayout.php | 14 | ||||
-rw-r--r-- | lib/private/legacy/OC_User.php | 26 |
2 files changed, 12 insertions, 28 deletions
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 82bd0fd22e7..16d4423838b 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -52,6 +52,7 @@ use OCP\Defaults; use OCP\IConfig; use OCP\IInitialStateService; use OCP\INavigationManager; +use OCP\IUserSession; use OCP\Support\Subscription\IRegistry; use OCP\Util; @@ -121,7 +122,12 @@ class TemplateLayout extends \OC_Template { break; } } - $userDisplayName = \OC_User::getDisplayName(); + + $userDisplayName = false; + $user = \OC::$server->get(IUserSession::class)->getUser(); + if ($user) { + $userDisplayName = $user->getDisplayName(); + } $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', \OC_User::getUser()); @@ -152,7 +158,11 @@ class TemplateLayout extends \OC_Template { \OC_Util::addStyle('guest'); $this->assign('bodyid', 'body-login'); - $userDisplayName = \OC_User::getDisplayName(); + $userDisplayName = false; + $user = \OC::$server->get(IUserSession::class)->getUser(); + if ($user) { + $userDisplayName = $user->getDisplayName(); + } $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', \OC_User::getUser()); } elseif ($renderAs === TemplateResponse::RENDER_AS_PUBLIC) { diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php index dd97fb63e33..f955c5c6938 100644 --- a/lib/private/legacy/OC_User.php +++ b/lib/private/legacy/OC_User.php @@ -329,32 +329,6 @@ class OC_User { } /** - * get the display name of the user currently logged in. - * - * @param string $uid - * @return string|bool uid or false - * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method - * get() of \OCP\IUserManager - \OC::$server->getUserManager() - */ - public static function getDisplayName($uid = null) { - if ($uid) { - $user = \OC::$server->getUserManager()->get($uid); - if ($user) { - return $user->getDisplayName(); - } else { - return $uid; - } - } else { - $user = \OC::$server->getUserSession()->getUser(); - if ($user) { - return $user->getDisplayName(); - } else { - return false; - } - } - } - - /** * Set password * * @param string $uid The username |