From: Tim Düsterhus Date: Wed, 17 Feb 2021 10:34:19 +0000 (+0100) Subject: Add PoC event listeners for authentication events X-Git-Tag: 5.5.0_Alpha_1~687^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5c8dc3b07bc3ad128975f7378744be58037b42ef;p=GitHub%2FWoltLab%2FWCF.git Add PoC event listeners for authentication events --- 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(); + } +}