diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-01-16 13:27:45 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-01-16 18:39:11 +0100 |
commit | 55532f19d90b40f7f46354b92a5322676729ba7e (patch) | |
tree | c29ee88dbb789c7c0aa9c9f1c08fccef27272d7f /lib | |
parent | a159d7c28c483a2b77e2f533795f6d6d1ec720fd (diff) | |
download | nextcloud-server-55532f19d90b40f7f46354b92a5322676729ba7e.tar.gz nextcloud-server-55532f19d90b40f7f46354b92a5322676729ba7e.zip |
Cleanup OC_User and OCP\User
* mainly removes deprecated methods and old static code
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Share/Share.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/json.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/user.php | 76 | ||||
-rw-r--r-- | lib/private/legacy/util.php | 2 | ||||
-rw-r--r-- | lib/public/User.php | 25 |
5 files changed, 7 insertions, 100 deletions
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 193e0c1a27e..5a88f57fb14 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -439,7 +439,7 @@ class Share extends Constants { \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); throw new \Exception($message_t); } - if (!\OC_User::userExists($shareWith)) { + if (!\OC::$server->getUserManager()->userExists($shareWith)) { $message = 'Sharing %s failed, because the user %s does not exist'; $message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith)); \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG); diff --git a/lib/private/legacy/json.php b/lib/private/legacy/json.php index 7b3a1b6d9cd..7bfc815ab24 100644 --- a/lib/private/legacy/json.php +++ b/lib/private/legacy/json.php @@ -118,7 +118,7 @@ class OC_JSON{ * @suppress PhanDeprecatedFunction */ public static function checkUserExists($user) { - if (!OCP\User::userExists($user)) { + if (!\OC::$server->getUserManager()->userExists($user)) { $l = \OC::$server->getL10N('lib'); OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' ))); exit; diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php index 52ed1369c47..8f342281adb 100644 --- a/lib/private/legacy/user.php +++ b/lib/private/legacy/user.php @@ -58,13 +58,6 @@ */ class OC_User { - /** - * @return \OC\User\Session - */ - public static function getUserSession() { - return OC::$server->getUserSession(); - } - private static $_usedBackends = array(); private static $_setupedBackends = array(); @@ -176,7 +169,7 @@ class OC_User { if ($uid) { if (self::getUser() !== $uid) { self::setUserId($uid); - $userSession = self::getUserSession(); + $userSession = \OC::$server->getUserSession(); $userSession->setLoginName($uid); $request = OC::$server->getRequest(); $userSession->createSessionToken($request, $uid, $uid); @@ -210,7 +203,7 @@ class OC_User { //setup extra user backends self::setupBackends(); - self::getUserSession()->unsetMagicInCookie(); + \OC::$server->getUserSession()->unsetMagicInCookie(); return self::loginWithApache($backend); } @@ -235,25 +228,6 @@ class OC_User { } /** - * Sets user display name for session - * - * @param string $uid - * @param string $displayName - * @return bool Whether the display name could get set - */ - public static function setDisplayName($uid, $displayName = null) { - if (is_null($displayName)) { - $displayName = $uid; - } - $user = \OC::$server->getUserManager()->get($uid); - if ($user) { - return $user->setDisplayName($displayName); - } else { - return false; - } - } - - /** * Check if the user is logged in, considers also the HTTP basic credentials * * @deprecated use \OC::$server->getUserSession()->isLoggedIn() @@ -348,7 +322,7 @@ class OC_User { return $uid; } } else { - $user = self::getUserSession()->getUser(); + $user = \OC::$server->getUserSession()->getUser(); if ($user) { return $user->getDisplayName(); } else { @@ -377,25 +351,6 @@ class OC_User { } /** - * Check if the password is correct - * - * @param string $uid The username - * @param string $password The password - * @return string|false user id a string on success, false otherwise - * - * Check if the password is correct without logging in the user - * returns the user id or false - */ - public static function checkPassword($uid, $password) { - $manager = \OC::$server->getUserManager(); - $username = $manager->checkPassword($uid, $password); - if ($username !== false) { - return $username->getUID(); - } - return false; - } - - /** * @param string $uid The username * @return string * @@ -451,31 +406,6 @@ class OC_User { } /** - * check if a user exists - * - * @param string $uid the username - * @return boolean - */ - public static function userExists($uid) { - return \OC::$server->getUserManager()->userExists($uid); - } - - /** - * checks if a user is enabled - * - * @param string $uid - * @return bool - */ - public static function isEnabled($uid) { - $user = \OC::$server->getUserManager()->get($uid); - if ($user) { - return $user->isEnabled(); - } else { - return false; - } - } - - /** * Returns the first active backend from self::$_usedBackends. * * @return OCP\Authentication\IApacheBackend|null if no backend active, otherwise OCP\Authentication\IApacheBackend diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index aaedd88a7ff..ca7cc1dc5cf 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -274,7 +274,7 @@ class OC_Util { self::initLocalStorageRootFS(); } - if ($user != '' && !OCP\User::userExists($user)) { + if ($user != '' && !\OC::$server->getUserManager()->userExists($user)) { \OC::$server->getEventLogger()->end('setup_fs'); return false; } diff --git a/lib/public/User.php b/lib/public/User.php index fd39b103d65..2fdf540b958 100644 --- a/lib/public/User.php +++ b/lib/public/User.php @@ -115,30 +115,7 @@ class User { * @since 5.0.0 */ public static function userExists($uid, $excludingBackend = null) { - return \OC_User::userExists($uid); - } - /** - * Logs the user out including all the session data - * Logout, destroys session - * @deprecated 8.0.0 Use \OC::$server->getUserSession()->logout(); - * @since 5.0.0 - */ - public static function logout() { - \OC::$server->getUserSession()->logout(); - } - - /** - * Check if the password is correct - * @param string $uid The username - * @param string $password The password - * @return string|false username on success, false otherwise - * - * Check if the password is correct without logging in the user - * @deprecated 8.0.0 Use \OC::$server->getUserManager()->checkPassword(); - * @since 5.0.0 - */ - public static function checkPassword( $uid, $password ) { - return \OC_User::checkPassword( $uid, $password ); + return \OC::$server->getUserManager()->userExists($uid); } /** |