|
|
|
|
@ -64,6 +64,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
|
|
|
|
|
@ -77,6 +78,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gets available backends
|
|
|
|
|
*
|
|
|
|
|
* @deprecated
|
|
|
|
|
* @return array an array of backends
|
|
|
|
|
*
|
|
|
|
|
@ -88,6 +90,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gets used backends
|
|
|
|
|
*
|
|
|
|
|
* @deprecated
|
|
|
|
|
* @return array an array of backends
|
|
|
|
|
*
|
|
|
|
|
@ -99,6 +102,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
|
|
|
|
|
*
|
|
|
|
|
@ -171,6 +175,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
|
|
|
|
|
@ -188,6 +193,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* delete a user
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid The username of the user to delete
|
|
|
|
|
* @return bool
|
|
|
|
|
*
|
|
|
|
|
@ -205,6 +211,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
|
|
|
|
|
@ -245,14 +252,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;
|
|
|
|
|
@ -286,11 +293,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
|
|
|
|
|
@ -320,13 +334,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() {
|
|
|
|
|
@ -339,6 +354,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) {
|
|
|
|
|
@ -347,6 +363,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get incognito mode status
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public static function isIncognitoMode() {
|
|
|
|
|
@ -371,6 +388,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the user is an admin user
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid uid of the admin
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
@ -384,6 +402,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the user id of the user currently logged in.
|
|
|
|
|
*
|
|
|
|
|
* @return string uid or false
|
|
|
|
|
*/
|
|
|
|
|
public static function getUser() {
|
|
|
|
|
@ -397,6 +416,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the display name of the user currently logged in.
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid
|
|
|
|
|
* @return string uid or false
|
|
|
|
|
*/
|
|
|
|
|
@ -420,6 +440,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Autogenerate a password
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*
|
|
|
|
|
* generates a password
|
|
|
|
|
@ -430,6 +451,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
|
|
|
|
|
@ -448,6 +470,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check whether user can change his avatar
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid The username
|
|
|
|
|
* @return bool
|
|
|
|
|
*
|
|
|
|
|
@ -464,6 +487,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check whether user can change his password
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid The username
|
|
|
|
|
* @return bool
|
|
|
|
|
*
|
|
|
|
|
@ -480,6 +504,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check whether user can change his display name
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid The username
|
|
|
|
|
* @return bool
|
|
|
|
|
*
|
|
|
|
|
@ -496,6 +521,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
|
|
|
|
|
@ -530,6 +556,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a list of all users
|
|
|
|
|
*
|
|
|
|
|
* @return array an array of all uids
|
|
|
|
|
*
|
|
|
|
|
* Get a list of all users.
|
|
|
|
|
@ -548,6 +575,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a list of all users display name
|
|
|
|
|
*
|
|
|
|
|
* @param string $search
|
|
|
|
|
* @param int $limit
|
|
|
|
|
* @param int $offset
|
|
|
|
|
@ -567,6 +595,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* check if a user exists
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid the username
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
@ -615,6 +644,7 @@ class OC_User {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set cookie value to use in next page load
|
|
|
|
|
*
|
|
|
|
|
* @param string $username username to be set
|
|
|
|
|
* @param string $token
|
|
|
|
|
*/
|
|
|
|
|
@ -631,6 +661,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() {
|
|
|
|
|
|