Merge pull request #23794 from owncloud/handle-null-in-usermanager
Prevent null to be passed into the closure of callForAllUsers
This commit is contained in:
commit
60f532882c
|
@ -33,6 +33,7 @@
|
||||||
namespace OC\User;
|
namespace OC\User;
|
||||||
|
|
||||||
use OC\Hooks\PublicEmitter;
|
use OC\Hooks\PublicEmitter;
|
||||||
|
use OCP\IUserBackend;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
|
||||||
|
@ -170,24 +171,24 @@ class Manager extends PublicEmitter implements IUserManager {
|
||||||
/**
|
/**
|
||||||
* Check if the password is valid for the user
|
* Check if the password is valid for the user
|
||||||
*
|
*
|
||||||
* @param string $loginname
|
* @param string $loginName
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @return mixed the User object on success, false otherwise
|
* @return mixed the User object on success, false otherwise
|
||||||
*/
|
*/
|
||||||
public function checkPassword($loginname, $password) {
|
public function checkPassword($loginName, $password) {
|
||||||
$loginname = str_replace("\0", '', $loginname);
|
$loginName = str_replace("\0", '', $loginName);
|
||||||
$password = str_replace("\0", '', $password);
|
$password = str_replace("\0", '', $password);
|
||||||
|
|
||||||
foreach ($this->backends as $backend) {
|
foreach ($this->backends as $backend) {
|
||||||
if ($backend->implementsActions(\OC_User_Backend::CHECK_PASSWORD)) {
|
if ($backend->implementsActions(\OC_User_Backend::CHECK_PASSWORD)) {
|
||||||
$uid = $backend->checkPassword($loginname, $password);
|
$uid = $backend->checkPassword($loginName, $password);
|
||||||
if ($uid !== false) {
|
if ($uid !== false) {
|
||||||
return $this->getUserObject($uid, $backend);
|
return $this->getUserObject($uid, $backend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
\OC::$server->getLogger()->warning('Login failed: \''. $loginname .'\' (Remote IP: \''. \OC::$server->getRequest()->getRemoteAddress(). '\')', ['app' => 'core']);
|
\OC::$server->getLogger()->warning('Login failed: \''. $loginName .'\' (Remote IP: \''. \OC::$server->getRequest()->getRemoteAddress(). '\')', ['app' => 'core']);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +305,7 @@ class Manager extends PublicEmitter implements IUserManager {
|
||||||
if ($backend->implementsActions(\OC_User_Backend::COUNT_USERS)) {
|
if ($backend->implementsActions(\OC_User_Backend::COUNT_USERS)) {
|
||||||
$backendUsers = $backend->countUsers();
|
$backendUsers = $backend->countUsers();
|
||||||
if($backendUsers !== false) {
|
if($backendUsers !== false) {
|
||||||
if($backend instanceof \OCP\IUserBackend) {
|
if($backend instanceof IUserBackend) {
|
||||||
$name = $backend->getBackendName();
|
$name = $backend->getBackendName();
|
||||||
} else {
|
} else {
|
||||||
$name = get_class($backend);
|
$name = get_class($backend);
|
||||||
|
@ -325,7 +326,7 @@ class Manager extends PublicEmitter implements IUserManager {
|
||||||
* If the callback returns false no further users will be retrieved.
|
* If the callback returns false no further users will be retrieved.
|
||||||
*
|
*
|
||||||
* @param \Closure $callback
|
* @param \Closure $callback
|
||||||
* @return void
|
* @param string $search
|
||||||
* @since 9.0.0
|
* @since 9.0.0
|
||||||
*/
|
*/
|
||||||
public function callForAllUsers(\Closure $callback, $search = '') {
|
public function callForAllUsers(\Closure $callback, $search = '') {
|
||||||
|
@ -336,6 +337,9 @@ class Manager extends PublicEmitter implements IUserManager {
|
||||||
$users = $backend->getUsers($search, $limit, $offset);
|
$users = $backend->getUsers($search, $limit, $offset);
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$user = $this->get($user);
|
$user = $this->get($user);
|
||||||
|
if (is_null($user)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$return = $callback($user);
|
$return = $callback($user);
|
||||||
if ($return === false) {
|
if ($return === false) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -90,12 +90,12 @@ interface IUserManager {
|
||||||
/**
|
/**
|
||||||
* Check if the password is valid for the user
|
* Check if the password is valid for the user
|
||||||
*
|
*
|
||||||
* @param string $loginname
|
* @param string $loginName
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @return mixed the User object on success, false otherwise
|
* @return mixed the User object on success, false otherwise
|
||||||
* @since 8.0.0
|
* @since 8.0.0
|
||||||
*/
|
*/
|
||||||
public function checkPassword($loginname, $password);
|
public function checkPassword($loginName, $password);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* search by user id
|
* search by user id
|
||||||
|
@ -138,7 +138,7 @@ interface IUserManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Closure $callback
|
* @param \Closure $callback
|
||||||
* @return void
|
* @param string $search
|
||||||
* @since 9.0.0
|
* @since 9.0.0
|
||||||
*/
|
*/
|
||||||
public function callForAllUsers (\Closure $callback, $search = '');
|
public function callForAllUsers (\Closure $callback, $search = '');
|
||||||
|
|
Loading…
Reference in New Issue