aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Server.php
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-15 15:28:30 +0200
committerGitHub <noreply@github.com>2022-08-15 15:28:30 +0200
commit51b9847fad73a1ca67dbf504358d90bd8f9e71d8 (patch)
treeb104cf1c540dd1dd195ca5fd30c42b888012cbab /lib/private/Server.php
parent6d6662ec68c8e15c4c6bfdf1c694794badd412d7 (diff)
parentcb97e8f15c75cc46e345ebfc79dcad1b9c48bd01 (diff)
downloadnextcloud-server-51b9847fad73a1ca67dbf504358d90bd8f9e71d8.tar.gz
nextcloud-server-51b9847fad73a1ca67dbf504358d90bd8f9e71d8.zip
Merge branch 'master' into display-name-cache-public
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private/Server.php')
-rw-r--r--lib/private/Server.php62
1 files changed, 13 insertions, 49 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index cc855eb0304..7223c3b8ae3 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -152,6 +152,8 @@ use OC\Tagging\TagMapper;
use OC\Talk\Broker;
use OC\Template\JSCombiner;
use OC\User\DisplayNameCache;
+use OC\User\Listeners\UserChangedListener;
+use OC\User\Listeners\UserDeletedListener;
use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
@@ -181,7 +183,6 @@ use OCP\Files\IMimeTypeLoader;
use OCP\Files\IRootFolder;
use OCP\Files\Lock\ILockManager;
use OCP\Files\Mount\IMountManager;
-use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorageFactory;
use OCP\Files\Template\ITemplateManager;
use OCP\FullTextSearch\IFullTextSearchManager;
@@ -218,7 +219,6 @@ use OCP\ISession;
use OCP\ITagManager;
use OCP\ITempManager;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
@@ -232,6 +232,7 @@ use OCP\Remote\Api\IApiFactory;
use OCP\Remote\IInstanceFactory;
use OCP\RichObjectStrings\IValidator;
use OCP\Route\IRouter;
+use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\IContentSecurityPolicyManager;
use OCP\Security\ICredentialsManager;
use OCP\Security\ICrypto;
@@ -250,6 +251,7 @@ use OCP\User\Events\BeforeUserLoggedOutEvent;
use OCP\User\Events\PasswordUpdatedEvent;
use OCP\User\Events\PostLoginEvent;
use OCP\User\Events\UserChangedEvent;
+use OCP\User\Events\UserDeletedEvent;
use OCP\User\Events\UserLoggedInEvent;
use OCP\User\Events\UserLoggedInWithCookieEvent;
use OCP\User\Events\UserLoggedOutEvent;
@@ -352,7 +354,7 @@ class Server extends ServerContainer implements IServerContainer {
return new Profiler($c->get(SystemConfig::class));
});
- $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
+ $this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
$view = new View();
$util = new Encryption\Util(
$view,
@@ -1006,6 +1008,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
/** @deprecated 19.0.0 */
$this->registerDeprecatedAlias('Throttler', Throttler::class);
+ $this->registerAlias(IThrottler::class, Throttler::class);
$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
// IConfig and IAppManager requires a working database. This code
// might however be called when ownCloud is not yet setup.
@@ -1478,52 +1481,13 @@ class Server extends ServerContainer implements IServerContainer {
return $this->get(\OC\Calendar\Room\Manager::class);
}
- private function connectDispatcher() {
- $dispatcher = $this->get(SymfonyAdapter::class);
-
- // Delete avatar on user deletion
- $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
- $logger = $this->get(LoggerInterface::class);
- $manager = $this->getAvatarManager();
- /** @var IUser $user */
- $user = $e->getSubject();
-
- try {
- $avatar = $manager->getAvatar($user->getUID());
- $avatar->remove();
- } catch (NotFoundException $e) {
- // no avatar to remove
- } catch (\Exception $e) {
- // Ignore exceptions
- $logger->info('Could not cleanup avatar of ' . $user->getUID());
- }
- });
-
- $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
- $manager = $this->getAvatarManager();
- /** @var IUser $user */
- $user = $e->getSubject();
- $feature = $e->getArgument('feature');
- $oldValue = $e->getArgument('oldValue');
- $value = $e->getArgument('value');
-
- // We only change the avatar on display name changes
- if ($feature !== 'displayName') {
- return;
- }
-
- try {
- $avatar = $manager->getAvatar($user->getUID());
- $avatar->userChanged($feature, $oldValue, $value);
- } catch (NotFoundException $e) {
- // no avatar to remove
- }
- });
-
- /** @var IEventDispatcher $eventDispatched */
- $eventDispatched = $this->get(IEventDispatcher::class);
- $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
- $eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
+ private function connectDispatcher(): void {
+ /** @var IEventDispatcher $eventDispatcher */
+ $eventDispatcher = $this->get(IEventDispatcher::class);
+ $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
+ $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
+ $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
+ $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
}
/**