summaryrefslogtreecommitdiffstats
path: root/lib/private/User/Manager.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-10-08 11:41:16 +0200
committerMorris Jobke <hey@morrisjobke.de>2020-12-02 15:20:03 +0100
commitd87705a8941511a4e3bf8f6c97d6e0f36a42799e (patch)
tree5c6d2ba0aed6a6c9b3bc0563ca800de65680bfea /lib/private/User/Manager.php
parente25a62c69dc83ba5655577181f4ea41a47c742b5 (diff)
downloadnextcloud-server-d87705a8941511a4e3bf8f6c97d6e0f36a42799e.tar.gz
nextcloud-server-d87705a8941511a4e3bf8f6c97d6e0f36a42799e.zip
Allow subscription to indicate that a userlimit is reached
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/User/Manager.php')
-rw-r--r--lib/private/User/Manager.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 1201a456ce2..1d58c68268c 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -34,6 +34,7 @@
namespace OC\User;
+use OC\HintException;
use OC\Hooks\PublicEmitter;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
@@ -42,6 +43,7 @@ use OCP\IGroup;
use OCP\IUser;
use OCP\IUserBackend;
use OCP\IUserManager;
+use OCP\Support\Subscription\IRegistry;
use OCP\User\Backend\IGetRealUIDBackend;
use OCP\User\Events\BeforeUserCreatedEvent;
use OCP\User\Events\UserCreatedEvent;
@@ -297,6 +299,12 @@ class Manager extends PublicEmitter implements IUserManager {
* @return bool|IUser the created user or false
*/
public function createUser($uid, $password) {
+ // DI injection is not used here as IRegistry needs the user manager itself for user count and thus it would create a cyclic dependency
+ if (\OC::$server->get(IRegistry::class)->delegateIsHardUserLimitReached()) {
+ $l = \OC::$server->getL10N('lib');
+ throw new HintException($l->t('The user limit has been reached and the user was not created.'));
+ }
+
$localBackends = [];
foreach ($this->backends as $backend) {
if ($backend instanceof Database) {