Skip to content

Commit 2fdb60d

Browse files
Merge pull request #60620 from nextcloud/backport/60516/stable30
[stable30] feat(users): Check assertion when enabling user
2 parents 088bc44 + 2e49349 commit 2fdb60d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/private/User/User.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use OCP\IUser;
2727
use OCP\IUserBackend;
2828
use OCP\Notification\IManager as INotificationManager;
29+
use OCP\Support\Subscription\IAssertion;
2930
use OCP\User\Backend\IGetHomeBackend;
3031
use OCP\User\Backend\IPasswordHashBackend;
3132
use OCP\User\Backend\IProvideAvatarBackend;
@@ -49,6 +50,7 @@ class User implements IUser {
4950

5051
private IConfig $config;
5152
private IURLGenerator $urlGenerator;
53+
private IAssertion $assertion;
5254

5355
/** @var IAccountManager */
5456
protected $accountManager;
@@ -77,11 +79,13 @@ public function __construct(
7779
private IEventDispatcher $dispatcher,
7880
$emitter = null,
7981
?IConfig $config = null,
80-
$urlGenerator = null,
82+
?IURLGenerator $urlGenerator = null,
83+
?IAssertion $assertion = null,
8184
) {
8285
$this->emitter = $emitter;
8386
$this->config = $config ?? \OCP\Server::get(IConfig::class);
8487
$this->urlGenerator = $urlGenerator ?? \OCP\Server::get(IURLGenerator::class);
88+
$this->assertion = $assertion ?? \OCP\Server::get(IAssertion::class);
8589
}
8690

8791
/**
@@ -466,6 +470,11 @@ public function setEnabled(bool $enabled = true) {
466470
$this->config->setUserValue($this->uid, 'core', 'enabled', $enabled ? 'true' : 'false');
467471
$this->enabled = $enabled;
468472
};
473+
474+
if ($oldStatus === false && $enabled === true) {
475+
$this->assertion->createUserIsLegit();
476+
}
477+
469478
if ($this->backend instanceof IProvideEnabledStateBackend) {
470479
$queryDatabaseValue = function (): bool {
471480
if ($this->enabled === null) {

0 commit comments

Comments
 (0)