From 1c1c8c0cc617fd65953771624c9eec6adc90e364 Mon Sep 17 00:00:00 2001 From: Exotical Date: Wed, 10 Jul 2024 06:30:12 +0200 Subject: [PATCH] Fix client Activity tab issues; fixes #465 (#466) * Remove deploy.locations from validator * Change location data to optional for backwards compat * Better styling * Add back comma to follow coding style * Remove EventServiceProvider from providers file Fixes duplicated auth messages in the client Activity tab. * Add null check on $model->actor Prevents the client Activity tab page from breaking when an authentication attempt has failed. * Proper type checking on $model->actor Chose instanceof as it seems to be the best in terms of type safety. Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> * Revert removal of EventServiceProvider * Remove subscription of AuthenticationListener * Remove subscriptions for auth events * Remove unused import Dispatcher * Remove unused import AuthenticationListener --------- Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> --- app/Listeners/Auth/AuthenticationListener.php | 7 ------- app/Providers/EventServiceProvider.php | 5 ----- app/Transformers/Api/Client/ActivityLogTransformer.php | 2 +- bootstrap/providers.php | 1 - 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/app/Listeners/Auth/AuthenticationListener.php b/app/Listeners/Auth/AuthenticationListener.php index 01a8e35c0..b06428bd2 100644 --- a/app/Listeners/Auth/AuthenticationListener.php +++ b/app/Listeners/Auth/AuthenticationListener.php @@ -5,7 +5,6 @@ namespace App\Listeners\Auth; use App\Facades\Activity; use Illuminate\Auth\Events\Failed; use App\Events\Auth\DirectLogin; -use Illuminate\Events\Dispatcher; class AuthenticationListener { @@ -28,10 +27,4 @@ class AuthenticationListener $activity->event($event instanceof Failed ? 'auth:fail' : 'auth:success')->log(); } - - public function subscribe(Dispatcher $events): void - { - $events->listen(Failed::class, self::class); - $events->listen(DirectLogin::class, self::class); - } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 88b8a3d01..e8b9a9a0d 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -10,7 +10,6 @@ use App\Observers\UserObserver; use App\Observers\ServerObserver; use App\Observers\SubuserObserver; use App\Observers\EggVariableObserver; -use App\Listeners\Auth\AuthenticationListener; use App\Events\Server\Installed as ServerInstalledEvent; use App\Notifications\ServerInstalled as ServerInstalledNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; @@ -24,10 +23,6 @@ class EventServiceProvider extends ServiceProvider ServerInstalledEvent::class => [ServerInstalledNotification::class], ]; - protected $subscribe = [ - AuthenticationListener::class, - ]; - /** * Register any events for your application. */ diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index af666beb6..488ad1c95 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -55,7 +55,7 @@ class ActivityLogTransformer extends BaseClientTransformer $properties = $model->properties ->mapWithKeys(function ($value, $key) use ($model) { - if ($key === 'ip' && !$model->actor->is($this->request->user())) { + if ($key === 'ip' && $model->actor instanceof User && !$model->actor->is($this->request->user())) { return [$key => '[hidden]']; } diff --git a/bootstrap/providers.php b/bootstrap/providers.php index 8c37bb7b5..a20d8785c 100644 --- a/bootstrap/providers.php +++ b/bootstrap/providers.php @@ -8,6 +8,5 @@ return [ App\Providers\Filament\AdminPanelProvider::class, App\Providers\RouteServiceProvider::class, App\Providers\ViewComposerServiceProvider::class, - SocialiteProviders\Manager\ServiceProvider::class, ];