Implement the UserLoggedIn event
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 1 Jul 2021 12:49:34 +0000 (14:49 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 2 Jul 2021 09:24:51 +0000 (11:24 +0200)
wcfsetup/install/files/lib/acp/form/LoginForm.class.php
wcfsetup/install/files/lib/action/FacebookAuthAction.class.php
wcfsetup/install/files/lib/action/GithubAuthAction.class.php
wcfsetup/install/files/lib/action/GoogleAuthAction.class.php
wcfsetup/install/files/lib/action/TwitterAuthAction.class.php
wcfsetup/install/files/lib/form/LoginForm.class.php
wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php

index 7d36887dec0a647defbb639091303d7e5a89e352..845e9f724cb2683b336b7911b7a61572d0582b83 100755 (executable)
@@ -8,12 +8,14 @@ use wcf\data\user\User;
 use wcf\data\user\UserProfile;
 use wcf\form\AbstractCaptchaForm;
 use wcf\system\application\ApplicationHandler;
+use wcf\system\event\EventHandler;
 use wcf\system\exception\NamedUserException;
 use wcf\system\exception\UserInputException;
 use wcf\system\request\LinkHandler;
 use wcf\system\request\RequestHandler;
 use wcf\system\request\RouteHandler;
 use wcf\system\user\authentication\EmailUserAuthentication;
+use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\user\authentication\UserAuthenticationFactory;
 use wcf\system\WCF;
 use wcf\util\HeaderUtil;
@@ -226,6 +228,10 @@ class LoginForm extends AbstractCaptchaForm
         $needsMultifactor = WCF::getSession()->changeUserAfterMultifactorAuthentication($this->user);
         if (!$needsMultifactor) {
             WCF::getSession()->registerReauthentication();
+
+            EventHandler::getInstance()->fire(
+                new UserLoggedIn($this->user)
+            );
         }
         $this->saved();
 
index c5276b384699bc43568fbea6a15335597a4cf57b..35bd06f3ed1e52c34bd56d2c0acf95d08eb89399 100644 (file)
@@ -5,8 +5,10 @@ namespace wcf\action;
 use GuzzleHttp\Psr7\Request;
 use wcf\data\user\User;
 use wcf\form\RegisterForm;
+use wcf\system\event\EventHandler;
 use wcf\system\exception\NamedUserException;
 use wcf\system\request\LinkHandler;
+use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\user\authentication\oauth\User as OauthUser;
 use wcf\system\WCF;
 use wcf\util\HeaderUtil;
@@ -135,6 +137,10 @@ final class FacebookAuthAction extends AbstractOauth2Action
 
                 WCF::getSession()->changeUser($user);
                 WCF::getSession()->update();
+                EventHandler::getInstance()->fire(
+                    new UserLoggedIn($user)
+                );
+
                 HeaderUtil::redirect(LinkHandler::getInstance()->getLink());
 
                 exit;
index a8a034e3b1b4224768bf0b6bd422b7c103d3c40d..1efc49a2b19b4836652b1563af410d114440988c 100644 (file)
@@ -6,8 +6,10 @@ use GuzzleHttp\Psr7\Request;
 use Psr\Http\Client\ClientExceptionInterface;
 use wcf\data\user\User;
 use wcf\form\RegisterForm;
+use wcf\system\event\EventHandler;
 use wcf\system\exception\NamedUserException;
 use wcf\system\request\LinkHandler;
+use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\user\authentication\oauth\User as OauthUser;
 use wcf\system\WCF;
 use wcf\util\HeaderUtil;
@@ -125,6 +127,10 @@ final class GithubAuthAction extends AbstractOauth2Action
 
                 WCF::getSession()->changeUser($user);
                 WCF::getSession()->update();
+                EventHandler::getInstance()->fire(
+                    new UserLoggedIn($user)
+                );
+
                 HeaderUtil::redirect(LinkHandler::getInstance()->getLink());
 
                 exit;
index 078e9b64259bee7b1af328f28e34af8fcfdde2d0..169d77bac91bc3ba400aa0a0ce2e2ce2b362236f 100644 (file)
@@ -5,8 +5,10 @@ namespace wcf\action;
 use GuzzleHttp\Psr7\Request;
 use wcf\data\user\User;
 use wcf\form\RegisterForm;
+use wcf\system\event\EventHandler;
 use wcf\system\exception\NamedUserException;
 use wcf\system\request\LinkHandler;
+use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\user\authentication\oauth\User as OauthUser;
 use wcf\system\WCF;
 use wcf\util\HeaderUtil;
@@ -147,6 +149,10 @@ final class GoogleAuthAction extends AbstractOauth2Action
 
                 WCF::getSession()->changeUser($user);
                 WCF::getSession()->update();
+                EventHandler::getInstance()->fire(
+                    new UserLoggedIn($user)
+                );
+
                 HeaderUtil::redirect(LinkHandler::getInstance()->getLink());
 
                 exit;
index 1975bd10e901b9159d7320aa9d984237cd0ab59a..5b287412c3d8db0fd1c7b22c774f11fe4c62f400 100644 (file)
@@ -8,10 +8,12 @@ use ParagonIE\ConstantTime\Base64;
 use ParagonIE\ConstantTime\Hex;
 use Psr\Http\Client\ClientExceptionInterface;
 use wcf\data\user\User;
+use wcf\system\event\EventHandler;
 use wcf\system\exception\NamedUserException;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\io\HttpFactory;
 use wcf\system\request\LinkHandler;
+use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\user\authentication\oauth\exception\StateValidationException;
 use wcf\system\user\authentication\oauth\User as OauthUser;
 use wcf\system\WCF;
@@ -121,6 +123,10 @@ class TwitterAuthAction extends AbstractAction
 
                 WCF::getSession()->changeUser($user);
                 WCF::getSession()->update();
+                EventHandler::getInstance()->fire(
+                    new UserLoggedIn($user)
+                );
+
                 HeaderUtil::redirect(LinkHandler::getInstance()->getLink());
 
                 exit;
index 95fadd5b494cc89271b73b5053dc494d844b054b..7dbd1c6a43d04aa9940df269449d528590ffb731 100644 (file)
@@ -2,7 +2,9 @@
 
 namespace wcf\form;
 
+use wcf\system\event\EventHandler;
 use wcf\system\request\LinkHandler;
+use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\WCF;
 
 /**
@@ -31,6 +33,12 @@ class LoginForm extends \wcf\acp\form\LoginForm
         // change user
         $needsMultifactor = WCF::getSession()->changeUserAfterMultifactorAuthentication($this->user);
 
+        if (!$needsMultifactor) {
+            EventHandler::getInstance()->fire(
+                new UserLoggedIn($this->user)
+            );
+        }
+
         $this->saved();
 
         // redirect to url
index 57c87c273f38853c0d61036419566addba9cee6a..4c0a5d194b15ef730e832b8b822e3f3bf75136bc 100644 (file)
@@ -6,10 +6,12 @@ use wcf\data\object\type\ObjectType;
 use wcf\data\user\User;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\event\EventHandler;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\NamedUserException;
 use wcf\system\form\builder\TemplateFormNode;
 use wcf\system\request\LinkHandler;
+use wcf\system\user\authentication\event\UserLoggedIn;
 use wcf\system\user\multifactor\IMultifactorMethod;
 use wcf\system\user\multifactor\Setup;
 use wcf\system\WCF;
@@ -144,6 +146,9 @@ class MultifactorAuthenticationForm extends AbstractFormBuilderForm
         WCF::getDB()->commitTransaction();
 
         WCF::getSession()->applyPendingUserChange($this->user);
+        EventHandler::getInstance()->fire(
+            new UserLoggedIn($this->user)
+        );
 
         $this->saved();
     }