Skip to content

Commit f8d9d50

Browse files
artongebackportbot[bot]
authored andcommitted
feat(users): Check assertion when enabling user
Signed-off-by: Louis Chmn <louis@chmn.me>
1 parent d0c2d97 commit f8d9d50

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
@@ -25,6 +25,7 @@
2525
use OCP\IUser;
2626
use OCP\IUserBackend;
2727
use OCP\Notification\IManager as INotificationManager;
28+
use OCP\Support\Subscription\IAssertion;
2829
use OCP\User\Backend\IGetHomeBackend;
2930
use OCP\User\Backend\IPasswordHashBackend;
3031
use OCP\User\Backend\IProvideAvatarBackend;
@@ -48,6 +49,7 @@ class User implements IUser {
4849

4950
private IConfig $config;
5051
private IURLGenerator $urlGenerator;
52+
private IAssertion $assertion;
5153

5254
/** @var IAccountManager */
5355
protected $accountManager;
@@ -76,11 +78,13 @@ public function __construct(
7678
private IEventDispatcher $dispatcher,
7779
$emitter = null,
7880
?IConfig $config = null,
79-
$urlGenerator = null,
81+
?IURLGenerator $urlGenerator = null,
82+
?IAssertion $assertion = null,
8083
) {
8184
$this->emitter = $emitter;
8285
$this->config = $config ?? \OCP\Server::get(IConfig::class);
8386
$this->urlGenerator = $urlGenerator ?? \OCP\Server::get(IURLGenerator::class);
87+
$this->assertion = $assertion ?? \OCP\Server::get(IAssertion::class);
8488
}
8589

8690
/**
@@ -484,6 +488,11 @@ public function setEnabled(bool $enabled = true) {
484488
$this->config->setUserValue($this->uid, 'core', 'enabled', $enabled ? 'true' : 'false');
485489
$this->enabled = $enabled;
486490
};
491+
492+
if ($oldStatus === false && $enabled === true) {
493+
$this->assertion->createUserIsLegit();
494+
}
495+
487496
if ($this->backend instanceof IProvideEnabledStateBackend) {
488497
$queryDatabaseValue = function (): bool {
489498
if ($this->enabled === null) {

0 commit comments

Comments
 (0)