/**
* registers backend
+ *
* @param string $backend name of the backend
* @deprecated Add classes by calling OC_User::useBackend() with a class instance instead
* @return bool
/**
* gets available backends
+ *
* @deprecated
* @return array an array of backends
*
/**
* gets used backends
+ *
* @deprecated
* @return array an array of backends
*
/**
* 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
*
/**
* 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
/**
* delete a user
+ *
* @param string $uid The username of the user to delete
* @return bool
*
/**
* 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
$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;
* 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
* 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() {
/**
* set incognito mode, e.g. if a user wants to open a public link
+ *
* @param bool $status
*/
public static function setIncognitoMode($status) {
/**
* get incognito mode status
+ *
* @return bool
*/
public static function isIncognitoMode() {
/**
* Check if the user is an admin user
+ *
* @param string $uid uid of the admin
* @return bool
*/
/**
* get the user id of the user currently logged in.
+ *
* @return string uid or false
*/
public static function getUser() {
/**
* get the display name of the user currently logged in.
+ *
* @param string $uid
* @return string uid or false
*/
/**
* Autogenerate a password
+ *
* @return string
*
* generates a password
/**
* Set password
+ *
* @param string $uid The username
* @param string $password The new password
* @param string $recoveryPassword for the encryption app to reset encryption keys
/**
* Check whether user can change his avatar
+ *
* @param string $uid The username
* @return bool
*
/**
* Check whether user can change his password
+ *
* @param string $uid The username
* @return bool
*
/**
* Check whether user can change his display name
+ *
* @param string $uid The username
* @return bool
*
/**
* 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
/**
* Get a list of all users
+ *
* @return array an array of all uids
*
* Get a list of all users.
/**
* Get a list of all users display name
+ *
* @param string $search
* @param int $limit
* @param int $offset
/**
* check if a user exists
+ *
* @param string $uid the username
* @return boolean
*/
/**
* Set cookie value to use in next page load
+ *
* @param string $username username to be set
* @param string $token
*/
/**
* 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() {