diff options
Diffstat (limited to 'lib/private/user.php')
-rw-r--r-- | lib/private/user.php | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/lib/private/user.php b/lib/private/user.php index 25b95f86080..5d3152247ec 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -66,6 +66,7 @@ class OC_User { /** * registers backend + * * @param string $backend name of the backend * @deprecated Add classes by calling OC_User::useBackend() with a class instance instead * @return bool @@ -79,6 +80,7 @@ class OC_User { /** * gets available backends + * * @deprecated * @return array an array of backends * @@ -90,6 +92,7 @@ class OC_User { /** * gets used backends + * * @deprecated * @return array an array of backends * @@ -101,6 +104,7 @@ class OC_User { /** * Adds the backend to the list of used backends + * * @param string|OC_User_Interface $backend default: database The backend to use for user management * @return bool * @@ -173,6 +177,7 @@ class OC_User { /** * Create a new user + * * @param string $uid The username of the user to create * @param string $password The password of the new user * @throws Exception @@ -190,6 +195,7 @@ class OC_User { /** * delete a user + * * @param string $uid The username of the user to delete * @return bool * @@ -207,6 +213,7 @@ class OC_User { /** * Try to login a user + * * @param string $loginname The login name of the user to log in * @param string $password The password of the user * @return boolean|null @@ -247,14 +254,14 @@ class OC_User { $uid = $backend->getCurrentUserId(); $run = true; - OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid )); + OC_Hook::emit("OC_User", "pre_login", array("run" => &$run, "uid" => $uid)); - if($uid) { + if ($uid) { self::setUserId($uid); self::setDisplayName($uid); self::getUserSession()->setLoginName($uid); - OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>'' )); + OC_Hook::emit("OC_User", "post_login", array("uid" => $uid, 'password' => '')); return true; } return false; @@ -288,11 +295,18 @@ class OC_User { * Sets user id for session and triggers emit */ public static function setUserId($uid) { - \OC::$server->getSession()->set('user_id', $uid); + $userSession = \OC::$server->getUserSession(); + $userManager = \OC::$server->getUserManager(); + if ($user = $userManager->get($uid)) { + $userSession->setUser($user); + } else { + \OC::$server->getSession()->set('user_id', $uid); + } } /** * Sets user display name for session + * * @param string $uid * @param null $displayName * @return bool Whether the display name could get set @@ -322,13 +336,14 @@ class OC_User { * Tries to login the user with HTTP Basic Authentication */ public static function tryBasicAuthLogin() { - if(!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { + if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { \OC_User::login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); } } /** * Check if the user is logged in, considers also the HTTP basic credentials + * * @return bool */ public static function isLoggedIn() { @@ -341,6 +356,7 @@ class OC_User { /** * set incognito mode, e.g. if a user wants to open a public link + * * @param bool $status */ public static function setIncognitoMode($status) { @@ -349,6 +365,7 @@ class OC_User { /** * get incognito mode status + * * @return bool */ public static function isIncognitoMode() { @@ -373,6 +390,7 @@ class OC_User { /** * Check if the user is an admin user + * * @param string $uid uid of the admin * @return bool */ @@ -386,6 +404,7 @@ class OC_User { /** * get the user id of the user currently logged in. + * * @return string uid or false */ public static function getUser() { @@ -399,6 +418,7 @@ class OC_User { /** * get the display name of the user currently logged in. + * * @param string $uid * @return string uid or false */ @@ -422,6 +442,7 @@ class OC_User { /** * Autogenerate a password + * * @return string * * generates a password @@ -432,6 +453,7 @@ class OC_User { /** * Set password + * * @param string $uid The username * @param string $password The new password * @param string $recoveryPassword for the encryption app to reset encryption keys @@ -450,6 +472,7 @@ class OC_User { /** * Check whether user can change his avatar + * * @param string $uid The username * @return bool * @@ -466,6 +489,7 @@ class OC_User { /** * Check whether user can change his password + * * @param string $uid The username * @return bool * @@ -482,6 +506,7 @@ class OC_User { /** * Check whether user can change his display name + * * @param string $uid The username * @return bool * @@ -498,6 +523,7 @@ 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 @@ -532,6 +558,7 @@ class OC_User { /** * Get a list of all users + * * @return array an array of all uids * * Get a list of all users. @@ -550,6 +577,7 @@ class OC_User { /** * Get a list of all users display name + * * @param string $search * @param int $limit * @param int $offset @@ -569,6 +597,7 @@ class OC_User { /** * check if a user exists + * * @param string $uid the username * @return boolean */ @@ -617,6 +646,7 @@ class OC_User { /** * Set cookie value to use in next page load + * * @param string $username username to be set * @param string $token */ @@ -633,6 +663,7 @@ class OC_User { /** * Returns the first active backend from self::$_usedBackends. + * * @return OCP\Authentication\IApacheBackend|null if no backend active, otherwise OCP\Authentication\IApacheBackend */ private static function findFirstActiveUsedBackend() { |