diff --git a/app/Events/Auth/DirectLogin.php b/app/Events/Auth/DirectLogin.php deleted file mode 100644 index 41643edb6..000000000 --- a/app/Events/Auth/DirectLogin.php +++ /dev/null @@ -1,11 +0,0 @@ -actor($user) + ->subject($user) ->subject($token->accessToken) ->property('identifier', $token->accessToken->identifier) ->log(); diff --git a/app/Filament/Pages/Auth/Login.php b/app/Filament/Pages/Auth/Login.php index 832a12087..24105168f 100644 --- a/app/Filament/Pages/Auth/Login.php +++ b/app/Filament/Pages/Auth/Login.php @@ -2,8 +2,10 @@ namespace App\Filament\Pages\Auth; +use App\Events\Auth\ProvidedAuthenticationToken; use App\Extensions\Captcha\Providers\CaptchaProvider; use App\Extensions\OAuth\Providers\OAuthProvider; +use App\Facades\Activity; use App\Models\User; use Filament\Facades\Filament; use Filament\Forms\Components\Actions; @@ -54,6 +56,11 @@ class Login extends BaseLogin if ($token === null) { $this->verifyTwoFactor = true; + Activity::event('auth:checkpoint') + ->withRequestMetadata() + ->subject($user) + ->log(); + return null; } @@ -64,11 +71,18 @@ class Login extends BaseLogin $token, Config::integer('panel.auth.2fa.window'), ); + + if ($isValidToken) { + event(new ProvidedAuthenticationToken($user)); + } } else { foreach ($user->recoveryTokens as $recoveryToken) { if (password_verify($token, $recoveryToken->token)) { $isValidToken = true; $recoveryToken->delete(); + + event(new ProvidedAuthenticationToken($user, true)); + break; } } diff --git a/app/Listeners/Auth/AuthenticationListener.php b/app/Listeners/Auth/AuthenticationListener.php index b06428bd2..5efaf0bff 100644 --- a/app/Listeners/Auth/AuthenticationListener.php +++ b/app/Listeners/Auth/AuthenticationListener.php @@ -4,7 +4,7 @@ namespace App\Listeners\Auth; use App\Facades\Activity; use Illuminate\Auth\Events\Failed; -use App\Events\Auth\DirectLogin; +use Illuminate\Auth\Events\Login; class AuthenticationListener { @@ -12,9 +12,10 @@ class AuthenticationListener * Handles an authentication event by logging the user and information about * the request. */ - public function handle(Failed|DirectLogin $event): void + public function handle(Failed|Login $event): void { $activity = Activity::withRequestMetadata(); + if ($event->user) { $activity = $activity->subject($event->user); } diff --git a/app/Listeners/Auth/PasswordResetListener.php b/app/Listeners/Auth/PasswordResetListener.php index 5daa84973..e64a96bee 100644 --- a/app/Listeners/Auth/PasswordResetListener.php +++ b/app/Listeners/Auth/PasswordResetListener.php @@ -2,22 +2,14 @@ namespace App\Listeners\Auth; -use Illuminate\Http\Request; use App\Facades\Activity; use Illuminate\Auth\Events\PasswordReset; class PasswordResetListener { - protected Request $request; - - public function __construct(Request $request) - { - $this->request = $request; - } - public function handle(PasswordReset $event): void { - Activity::event('event:password-reset') + Activity::event('auth:password-reset') ->withRequestMetadata() ->subject($event->user) ->log();