summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
Commit message (Expand)AuthorAgeFilesLines
* Fix type hintingRobin Appelman2016-07-082-2/+2
* Fix undefined propertiesRobin Appelman2016-07-083-0/+14
* Merge branch 'master' into sync-masterMorris Jobke2016-07-071-3/+29
|\
| * Merge remote-tracking branch 'upstream/master' into master-sync-upstreamLukas Reschke2016-07-011-2/+12
| |\
| * | fix error messageBjoern Schiessle2016-06-301-1/+1
| * | Add proper throws PHP docsLukas Reschke2016-06-301-2/+13
| * | Add required $message parameterLukas Reschke2016-06-301-2/+2
| * | add some additonal permission checks to the webdav backendBjoern Schiessle2016-06-301-1/+16
| * | get only vcard which match both the address book id and the vcard uriBjoern Schiessle2016-06-281-1/+1
* | | Add all properties while creating a subscription (#25318)Thomas Citharel2016-07-011-10/+15
| |/ |/|
* | get only vcards which match both the address book id and the vcard uri (#25294)Björn Schießle2016-06-291-1/+1
* | fix a ImageExportPlugin Test (#25215)Georg Ehrke2016-06-271-2/+12
|/
* Show error message when posting an invalid commentVincent Petry2016-06-241-1/+1
* Contacts API: replace raw image data with url (#25081)Georg Ehrke2016-06-216-19/+198
* PasswordLoginForbidden must extend NotAuthenticatedVincent Petry2016-06-171-2/+2
* throw PasswordLoginForbidden on DAVChristoph Wurst2016-06-172-2/+56
* add PasswordLoginForbiddenExceptionChristoph Wurst2016-06-171-6/+13
* Move birthday calendar generation to a live migration job (#25135)Thomas Müller2016-06-162-14/+81
* create session token on all APIsChristoph Wurst2016-06-131-2/+1
* Merge pull request #24080 from owncloud/support-calendar-class-propertyVincent Petry2016-06-105-25/+337
|\
| * Filter confidential calendar objects in shared calendarsThomas Müller2016-06-093-3/+172
| * Added unit testing for the migration stepThomas Müller2016-06-092-4/+12
| * Implement classification migration as repair stepThomas Müller2016-06-093-57/+101
| * Bump dav app version and fix variable renameThomas Müller2016-06-091-2/+2
| * Add migration stepThomas Müller2016-06-092-0/+59
| * Extract CLASS property from calendar object and store it in the databaseThomas Müller2016-06-091-21/+53
* | Merge pull request #25046 from owncloud/fix-the-realmVincent Petry2016-06-103-4/+12
|\ \
| * | Use the correct realm for basic authentication - fixes #23427Thomas Müller2016-06-093-4/+12
| |/
* | Merge pull request #25043 from owncloud/webdav-download-mimetypeVincent Petry2016-06-103-1/+24
|\ \
| * | DAV now returns file name with Content-Disposition headerVincent Petry2016-06-093-1/+24
| |/
* / Allow login by email address via webdav as well - fixes #24791Thomas Müller2016-06-091-2/+2
|/
* Better handling of forbidden files in davRobin Appelman2016-06-072-0/+4
* Fix checkMove() implementation for dav v2 - fixes #24776 (#24971)Thomas Müller2016-06-062-5/+8
* Merge pull request #24935 from owncloud/2fa-block-davVincent Petry2016-06-022-3/+14
|\
| * block DAV if 2FA challenge needs to be solved firstChristoph Wurst2016-06-012-3/+14
* | Catch the ForbiddenException to make sure it gets handledJoas Schilling2016-06-011-0/+3
|/
* Update license headersLukas Reschke2016-05-2647-50/+163
* do not allow client password logins if token auth is enforced or 2FA is enabledChristoph Wurst2016-05-241-2/+1
* when generating browser/device token, save the login name for later password ...Christoph Wurst2016-05-241-1/+1
* Merge pull request #24559 from owncloud/2faVincent Petry2016-05-231-0/+1
|\
| * Add two factor auth to coreChristoph Wurst2016-05-231-0/+1
* | Merge pull request #22690 from owncloud/fix-comments-href-remote.php-filesVincent Petry2016-05-231-3/+3
|\ \ | |/ |/|
| * ensure comments-href returns a value also when propfind is done against remot...Arthur Schiwon2016-05-201-3/+3
* | Make the root collection neutral so it does not only work for filesJoas Schilling2016-05-233-30/+40
* | Remove unused UserFolderJoas Schilling2016-05-232-15/+5
* | Adjust DAV SystemTagPlugin unit tests for groupsVincent Petry2016-05-201-16/+25
* | Fix system tag update codeVincent Petry2016-05-201-0/+4
* | Add admin-only system tag groups propertyVincent Petry2016-05-201-4/+39
* | Act on effective system tag canAssign permissionVincent Petry2016-05-201-1/+8
* | Fix system tags DAV unit testsVincent Petry2016-05-202-5/+62
an class="k">function createUser($uid, $password) { if (!$this->userExists($uid)) { $event = new GenericEvent($password); $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); $query = \OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )'); $result = $query->execute(array($uid, \OC::$server->getHasher()->hash($password))); // Clear cache unset($this->cache[$uid]); return $result ? true : false; } return false; } /** * delete a user * @param string $uid The username of the user to delete * @return bool * * Deletes a user */ public function deleteUser($uid) { // Delete user-group-relation $query = \OC_DB::prepare('DELETE FROM `*PREFIX*users` WHERE `uid` = ?'); $result = $query->execute(array($uid)); if (isset($this->cache[$uid])) { unset($this->cache[$uid]); } return $result ? true : false; } /** * Set password * @param string $uid The username * @param string $password The new password * @return bool * * Change the password of a user */ public function setPassword($uid, $password) { if ($this->userExists($uid)) { $event = new GenericEvent($password); $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); $query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?'); $result = $query->execute(array(\OC::$server->getHasher()->hash($password), $uid)); return $result ? true : false; } return false; } /** * Set display name * @param string $uid The username * @param string $displayName The new display name * @return bool * * Change the display name of a user */ public function setDisplayName($uid, $displayName) { if ($this->userExists($uid)) { $query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = LOWER(?)'); $query->execute(array($displayName, $uid)); $this->cache[$uid]['displayname'] = $displayName; return true; } return false; } /** * get display name of the user * @param string $uid user ID of the user * @return string display name */ public function getDisplayName($uid) { $this->loadUser($uid); return empty($this->cache[$uid]['displayname']) ? $uid : $this->cache[$uid]['displayname']; } /** * Get a list of all display names and user ids. * * @param string $search * @param string|null $limit * @param string|null $offset * @return array an array of all displayNames (value) and the corresponding uids (key) */ public function getDisplayNames($search = '', $limit = null, $offset = null) { $parameters = []; $searchLike = ''; if ($search !== '') { $parameters[] = '%' . $search . '%'; $parameters[] = '%' . $search . '%'; $searchLike = ' WHERE LOWER(`displayname`) LIKE LOWER(?) OR ' . 'LOWER(`uid`) LIKE LOWER(?)'; } $displayNames = array(); $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`' . $searchLike .' ORDER BY `uid` ASC', $limit, $offset); $result = $query->execute($parameters); while ($row = $result->fetchRow()) { $displayNames[$row['uid']] = $row['displayname']; } return $displayNames; } /** * Check if the password is correct * @param string $uid The username * @param string $password The password * @return string * * Check if the password is correct without logging in the user * returns the user id or false */ public function checkPassword($uid, $password) { $query = \OC_DB::prepare('SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); $result = $query->execute(array($uid)); $row = $result->fetchRow(); if ($row) { $storedHash = $row['password']; $newHash = ''; if(\OC::$server->getHasher()->verify($password, $storedHash, $newHash)) { if(!empty($newHash)) { $this->setPassword($uid, $password); } return $row['uid']; } } return false; } /** * Load an user in the cache * @param string $uid the username * @return boolean */ private function loadUser($uid) { if (!isset($this->cache[$uid])) { $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); $result = $query->execute(array($uid)); if ($result === false) { Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR); return false; } $this->cache[$uid] = false; while ($row = $result->fetchRow()) { $this->cache[$uid]['uid'] = $row['uid']; $this->cache[$uid]['displayname'] = $row['displayname']; } } return true; } /** * Get a list of all users * * @param string $search * @param null|int $limit * @param null|int $offset * @return string[] an array of all uids */ public function getUsers($search = '', $limit = null, $offset = null) { $parameters = []; $searchLike = ''; if ($search !== '') { $parameters[] = '%' . $search . '%'; $searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)'; } $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset); $result = $query->execute($parameters); $users = array(); while ($row = $result->fetchRow()) { $users[] = $row['uid']; } return $users; } /** * check if a user exists * @param string $uid the username * @return boolean */ public function userExists($uid) { $this->loadUser($uid); return $this->cache[$uid] !== false; } /** * get the user's home directory * @param string $uid the username * @return string|false */ public function getHome($uid) { if ($this->userExists($uid)) { return \OC::$server->getConfig()->getSystemValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $uid; } return false; } /** * @return bool */ public function hasUserListings() { return true; } /** * counts the users in the database * * @return int|bool */ public function countUsers() { $query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); $result = $query->execute(); if ($result === false) { Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR); return false; } return $result->fetchOne(); } /** * returns the username for the given login name in the correct casing * * @param string $loginName * @return string|false */ public function loginName2UserName($loginName) { if ($this->userExists($loginName)) { return $this->cache[$loginName]['uid']; } return false; } /** * Backend name to be shown in user management * @return string the name of the backend to be shown */ public function getBackendName(){ return 'Database'; } public static function preLoginNameUsedAsUserName($param) { if(!isset($param['uid'])) { throw new \Exception('key uid is expected to be set in $param'); } $backends = \OC::$server->getUserManager()->getBackends(); foreach ($backends as $backend) { if ($backend instanceof Database) { /** @var \OC\User\Database $backend */ $uid = $backend->loginName2UserName($param['uid']); if ($uid !== false) { $param['uid'] = $uid; return; } } } } }