From: Tim Düsterhus Date: Thu, 1 Jul 2021 12:49:34 +0000 (+0200) Subject: Implement the UserLoggedIn event X-Git-Tag: 5.5.0_Alpha_1~582^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=301d5ea43eb4864410c90843cdcda2b14d937737;p=GitHub%2FWoltLab%2FWCF.git Implement the UserLoggedIn event --- diff --git a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php index 7d36887dec..845e9f724c 100755 --- a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php @@ -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(); diff --git a/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php b/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php index c5276b3846..35bd06f3ed 100644 --- a/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php +++ b/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php @@ -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; diff --git a/wcfsetup/install/files/lib/action/GithubAuthAction.class.php b/wcfsetup/install/files/lib/action/GithubAuthAction.class.php index a8a034e3b1..1efc49a2b1 100644 --- a/wcfsetup/install/files/lib/action/GithubAuthAction.class.php +++ b/wcfsetup/install/files/lib/action/GithubAuthAction.class.php @@ -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; diff --git a/wcfsetup/install/files/lib/action/GoogleAuthAction.class.php b/wcfsetup/install/files/lib/action/GoogleAuthAction.class.php index 078e9b6425..169d77bac9 100644 --- a/wcfsetup/install/files/lib/action/GoogleAuthAction.class.php +++ b/wcfsetup/install/files/lib/action/GoogleAuthAction.class.php @@ -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; diff --git a/wcfsetup/install/files/lib/action/TwitterAuthAction.class.php b/wcfsetup/install/files/lib/action/TwitterAuthAction.class.php index 1975bd10e9..5b287412c3 100644 --- a/wcfsetup/install/files/lib/action/TwitterAuthAction.class.php +++ b/wcfsetup/install/files/lib/action/TwitterAuthAction.class.php @@ -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; diff --git a/wcfsetup/install/files/lib/form/LoginForm.class.php b/wcfsetup/install/files/lib/form/LoginForm.class.php index 95fadd5b49..7dbd1c6a43 100644 --- a/wcfsetup/install/files/lib/form/LoginForm.class.php +++ b/wcfsetup/install/files/lib/form/LoginForm.class.php @@ -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 diff --git a/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php b/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php index 57c87c273f..4c0a5d194b 100644 --- a/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php +++ b/wcfsetup/install/files/lib/form/MultifactorAuthenticationForm.class.php @@ -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(); }