From 5c8dc3b07bc3ad128975f7378744be58037b42ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 17 Feb 2021 11:34:19 +0100 Subject: [PATCH] Add PoC event listeners for authentication events --- com.woltlab.wcf/eventListener.xml | 12 +++++++ ...oggedInEmailNotificationListener.class.php | 31 +++++++++++++++++++ ...cceededEmailNotificationListener.class.php | 31 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/event/listener/UserLoggedInEmailNotificationListener.class.php create mode 100644 wcfsetup/install/files/lib/system/event/listener/UserMultifactorSucceededEmailNotificationListener.class.php diff --git a/com.woltlab.wcf/eventListener.xml b/com.woltlab.wcf/eventListener.xml index e7beec0941..a3fddcea1a 100644 --- a/com.woltlab.wcf/eventListener.xml +++ b/com.woltlab.wcf/eventListener.xml @@ -39,5 +39,17 @@ wcf\system\event\listener\UserLinkHtmlInputNodeProcessorListener all + + wcf\system\user\authentication\UserLoggedIn + :default + wcf\system\event\listener\UserLoggedInEmailNotificationListener + all + + + wcf\system\user\authentication\UserMultifactorSucceeded + :default + wcf\system\event\listener\UserMultifactorSucceededEmailNotificationListener + all + diff --git a/wcfsetup/install/files/lib/system/event/listener/UserLoggedInEmailNotificationListener.class.php b/wcfsetup/install/files/lib/system/event/listener/UserLoggedInEmailNotificationListener.class.php new file mode 100644 index 0000000000..7d8ce0668d --- /dev/null +++ b/wcfsetup/install/files/lib/system/event/listener/UserLoggedInEmailNotificationListener.class.php @@ -0,0 +1,31 @@ + + * @package WoltLabSuite\Core\System\Event\Listener + */ +final class UserLoggedInEmailNotificationListener implements IParameterizedEventListener +{ + /** + * @inheritDoc + * @param UserLoggedIn $eventObj + */ + public function execute($eventObj, $className, $eventName, array &$parameters) + { + $email = new SimpleEmail(); + $email->setRecipient($eventObj->getUser()); + $email->setSubject("You logged in"); + $email->setMessage("You logged in"); + $email->setHtmlMessage("You logged in"); + $email->send(); + } +} diff --git a/wcfsetup/install/files/lib/system/event/listener/UserMultifactorSucceededEmailNotificationListener.class.php b/wcfsetup/install/files/lib/system/event/listener/UserMultifactorSucceededEmailNotificationListener.class.php new file mode 100644 index 0000000000..17cac351ef --- /dev/null +++ b/wcfsetup/install/files/lib/system/event/listener/UserMultifactorSucceededEmailNotificationListener.class.php @@ -0,0 +1,31 @@ + + * @package WoltLabSuite\Core\System\Event\Listener + */ +final class UserMultifactorSucceededEmailNotificationListener implements IParameterizedEventListener +{ + /** + * @inheritDoc + * @param UserMultifactorSucceeded $eventObj + */ + public function execute($eventObj, $className, $eventName, array &$parameters) + { + $email = new SimpleEmail(); + $email->setRecipient($eventObj->getUser()); + $email->setSubject("You performed MFA with {$eventObj->getSetup()->getObjectType()->objectType}"); + $email->setMessage("You performed MFA with {$eventObj->getSetup()->getObjectType()->objectType}"); + $email->setHtmlMessage("You performed MFA with {$eventObj->getSetup()->getObjectType()->objectType}"); + $email->send(); + } +} -- 2.20.1