Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/admin_audit/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Authentication\Events\AnyLoginFailedEvent;
use OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengeFailed;
use OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengePassed;
use OCP\Console\ConsoleEvent;
Expand Down Expand Up @@ -105,6 +106,7 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(UserLoggedInWithCookieEvent::class, AuthEventListener::class);
$context->registerEventListener(UserLoggedInEvent::class, AuthEventListener::class);
$context->registerEventListener(BeforeUserLoggedOutEvent::class, AuthEventListener::class);
$context->registerEventListener(AnyLoginFailedEvent::class, AuthEventListener::class);

// File events
$context->registerEventListener(BeforePreviewFetchedEvent::class, FileEventListener::class);
Expand Down
18 changes: 17 additions & 1 deletion apps/admin_audit/lib/Listener/AuthEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OCA\AdminAudit\Listener;

use OCA\AdminAudit\Actions\Action;
use OCP\Authentication\Events\AnyLoginFailedEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\User\Events\BeforeUserLoggedInEvent;
Expand All @@ -18,7 +19,7 @@
use OCP\User\Events\UserLoggedInWithCookieEvent;

/**
* @template-implements IEventListener<BeforeUserLoggedInEvent|UserLoggedInWithCookieEvent|UserLoggedInEvent|BeforeUserLoggedOutEvent>
* @template-implements IEventListener<BeforeUserLoggedInEvent|UserLoggedInWithCookieEvent|UserLoggedInEvent|BeforeUserLoggedOutEvent|AnyLoginFailedEvent>
*/
class AuthEventListener extends Action implements IEventListener {
public function handle(Event $event): void {
Expand All @@ -28,6 +29,8 @@ public function handle(Event $event): void {
$this->userLoggedIn($event);
} elseif ($event instanceof BeforeUserLoggedOutEvent) {
$this->beforeUserLogout($event);
} elseif ($event instanceof AnyLoginFailedEvent) {
$this->anyLoginFailed($event);
}
}

Expand Down Expand Up @@ -64,4 +67,17 @@ private function beforeUserLogout(BeforeUserLoggedOutEvent $event): void {
[]
);
}

private function anyLoginFailed(AnyLoginFailedEvent $event): void {
$this->log(
'Login failed: "%s"',
[
'loginName' => $event->getLoginName()
],
[
'loginName',
],
true
);
}
}
8 changes: 8 additions & 0 deletions lib/public/Authentication/Events/AnyLoginFailedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ public function __construct(string $loginName, ?string $password) {

/**
* @since 26.0.0
* @deprecated 31.0.0 Use getLoginName() instead
*/
public function geLoginName(): string {
return $this->loginName;
}

/**
* @since 31.0.0
*/
public function getLoginName(): string {
return $this->loginName;
}

/**
* @since 26.0.0
*/
Expand Down
Loading