diff options
Diffstat (limited to 'lib/private/Authentication/Login')
-rw-r--r-- | lib/private/Authentication/Login/LoggedInCheckCommand.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/private/Authentication/Login/LoggedInCheckCommand.php b/lib/private/Authentication/Login/LoggedInCheckCommand.php index 9c1e45e0db7..78f27bfa937 100644 --- a/lib/private/Authentication/Login/LoggedInCheckCommand.php +++ b/lib/private/Authentication/Login/LoggedInCheckCommand.php @@ -25,24 +25,36 @@ declare(strict_types=1); namespace OC\Authentication\Login; +use OC\Authentication\Events\LoginFailed; use OC\Core\Controller\LoginController; +use OCP\Authentication\Events\LoginFailedEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\ILogger; +use OCP\IUserManager; +use OCP\Util; class LoggedInCheckCommand extends ALoginCommand { /** @var ILogger */ private $logger; + /** @var IEventDispatcher */ + private $dispatcher; + /** @var IUserManager */ + private $userManager; - public function __construct(ILogger $logger) { + public function __construct(ILogger $logger, IEventDispatcher $dispatcher) { $this->logger = $logger; + $this->dispatcher = $dispatcher; } public function process(LoginData $loginData): LoginResult { if ($loginData->getUser() === false) { - $username = $loginData->getUsername(); + $loginName = $loginData->getUsername(); $ip = $loginData->getRequest()->getRemoteAddress(); - $this->logger->warning("Login failed: $username (Remote IP: $ip)"); + $this->logger->warning("Login failed: $loginName (Remote IP: $ip)"); + + $this->dispatcher->dispatchTyped(new LoginFailed($loginName)); return LoginResult::failure($loginData, LoginController::LOGIN_MSG_INVALIDPASSWORD); } |