Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/password_policy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2019-11-27 12:45:30 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-11-27 12:47:34 +0300
commit8eaa09061c37e913405545527870d77f0e754639 (patch)
tree9bf9f9366768434ee060e9a0bff293cb1e2e8145 /lib
parentc7885fb30dea0f60c6fd12e940841e8b0698aade (diff)
Listen for legacy events as well
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index f4033a4..728f4a7 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -30,6 +30,7 @@ use OCA\Password_Policy\PasswordValidator;
use OCP\AppFramework\App;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\ILogger;
use OCP\Security\Events\GenerateSecurePasswordEvent;
use OCP\Security\Events\ValidatePasswordPolicyEvent;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -70,5 +71,32 @@ class Application extends App {
$event->setPassword($generator->generate());
}
);
+
+ // TODO: remove these two legacy event listeners
+ $symfonyDispatcher = $server->getEventDispatcher();
+ $symfonyDispatcher->addListener(
+ 'OCP\PasswordPolicy::validate',
+ function (GenericEvent $event) use ($container) {
+ /** @var ILogger $logger */
+ $logger = $container->query(ILogger::class);
+ $logger->debug('OCP\PasswordPolicy::validate is deprecated. Listen to ' . ValidatePasswordPolicyEvent::class . ' instead');
+
+ /** @var PasswordValidator $validator */
+ $validator = $container->query(PasswordValidator::class);
+ $validator->validate($event->getSubject());
+ }
+ );
+ $symfonyDispatcher->addListener(
+ 'OCP\PasswordPolicy::generate',
+ function (GenericEvent $event) use ($container) {
+ /** @var ILogger $logger */
+ $logger = $container->query(ILogger::class);
+ $logger->debug('OCP\PasswordPolicy::generate is deprecated. Listen to ' . GenerateSecurePasswordEvent::class . ' instead');
+
+ /** @var Generator */
+ $generator = $container->query(Generator::class);
+ $event->setArgument('password', $generator->generate());
+ }
+ );
}
}