mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
fix(files_external): Properly register event listeners in register method
This is the clean solution, LoginCredentials was the only auth class actually registering stuff in constructor. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
3279afc529
commit
69b85fab32
2 changed files with 5 additions and 16 deletions
|
|
@ -42,6 +42,7 @@ use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
|
|||
use OCA\Files_External\Lib\Config\IBackendProvider;
|
||||
use OCA\Files_External\Listener\GroupDeletedListener;
|
||||
use OCA\Files_External\Listener\LoadAdditionalListener;
|
||||
use OCA\Files_External\Listener\StorePasswordListener;
|
||||
use OCA\Files_External\Listener\UserDeletedListener;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCP\AppFramework\App;
|
||||
|
|
@ -51,7 +52,9 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
|||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Files\Config\IMountProviderCollection;
|
||||
use OCP\Group\Events\GroupDeletedEvent;
|
||||
use OCP\User\Events\PasswordUpdatedEvent;
|
||||
use OCP\User\Events\UserDeletedEvent;
|
||||
use OCP\User\Events\UserLoggedInEvent;
|
||||
|
||||
/**
|
||||
* @package OCA\Files_External\AppInfo
|
||||
|
|
@ -72,6 +75,8 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
|
|||
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
|
||||
$context->registerEventListener(GroupDeletedEvent::class, GroupDeletedListener::class);
|
||||
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
|
||||
$context->registerEventListener(UserLoggedInEvent::class, StorePasswordListener::class);
|
||||
$context->registerEventListener(PasswordUpdatedEvent::class, StorePasswordListener::class);
|
||||
$context->registerConfigLexicon(ConfigLexicon::class);
|
||||
}
|
||||
|
||||
|
|
@ -86,14 +91,6 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
|
|||
return $userConfigHandler;
|
||||
});
|
||||
});
|
||||
|
||||
// force-load auth mechanisms since some will register hooks
|
||||
// TODO: obsolete these and use the TokenProvider to get the user's password from the session
|
||||
$objects = $this->getAuthMechanisms();
|
||||
foreach ($objects as $object) {
|
||||
/* Use the object to trigger DI on PHP >= 8.4 */
|
||||
get_object_vars($object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,18 +11,14 @@ use OCA\Files_External\Lib\Auth\AuthMechanism;
|
|||
use OCA\Files_External\Lib\DefinitionParameter;
|
||||
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\Listener\StorePasswordListener;
|
||||
use OCP\Authentication\Exceptions\CredentialsUnavailableException;
|
||||
use OCP\Authentication\LoginCredentials\IStore as CredentialsStore;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IL10N;
|
||||
use OCP\ISession;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserBackend;
|
||||
use OCP\LDAP\ILDAPProviderFactory;
|
||||
use OCP\Security\ICredentialsManager;
|
||||
use OCP\User\Events\PasswordUpdatedEvent;
|
||||
use OCP\User\Events\UserLoggedInEvent;
|
||||
|
||||
/**
|
||||
* Username and password from login credentials, saved in DB
|
||||
|
|
@ -35,7 +31,6 @@ class LoginCredentials extends AuthMechanism {
|
|||
protected ISession $session,
|
||||
protected ICredentialsManager $credentialsManager,
|
||||
private CredentialsStore $credentialsStore,
|
||||
IEventDispatcher $eventDispatcher,
|
||||
private ILDAPProviderFactory $ldapFactory,
|
||||
) {
|
||||
$this
|
||||
|
|
@ -48,9 +43,6 @@ class LoginCredentials extends AuthMechanism {
|
|||
->setFlag(DefinitionParameter::FLAG_HIDDEN)
|
||||
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
|
||||
]);
|
||||
|
||||
$eventDispatcher->addServiceListener(UserLoggedInEvent::class, StorePasswordListener::class);
|
||||
$eventDispatcher->addServiceListener(PasswordUpdatedEvent::class, StorePasswordListener::class);
|
||||
}
|
||||
|
||||
private function getCredentials(IUser $user): array {
|
||||
|
|
|
|||
Loading…
Reference in a new issue