diff --git a/app/Events/AuthLoginEvent.php b/app/Listeners/AuthLogin.php similarity index 50% rename from app/Events/AuthLoginEvent.php rename to app/Listeners/AuthLogin.php index 72c6e74e6..e8a274e06 100644 --- a/app/Events/AuthLoginEvent.php +++ b/app/Listeners/AuthLogin.php @@ -1,19 +1,16 @@ user; if (empty($user->settings)) { $settings = new UserSetting(); $settings->user_id = $user->id; diff --git a/app/Listeners/LogFailedLogin.php b/app/Listeners/LogFailedLogin.php new file mode 100644 index 000000000..e289ea577 --- /dev/null +++ b/app/Listeners/LogFailedLogin.php @@ -0,0 +1,44 @@ +user; + $request = request(); + + $log = new AccountLog(); + $log->user_id = $user->id; + $log->item_id = $user->id; + $log->item_type = 'App\User'; + $log->action = 'auth.failed'; + $log->message = 'Failed login attempt'; + $log->link = null; + $log->ip_address = $request->ip(); + $log->user_agent = $request->userAgent(); + $log->save(); + } +} diff --git a/app/Profile.php b/app/Profile.php index 4baef2ba2..92d1bad3f 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -205,4 +205,19 @@ class Profile extends Model { return $this->hasMany(Media::class, 'profile_id'); } + + public function inboxUrl() + { + return $this->inbox_url ?? $this->permalink('/inbox'); + } + + public function outboxUrl() + { + return $this->outbox_url ?? $this->permalink('/outbox'); + } + + public function sharedInbox() + { + return $this->sharedInbox ?? $this->inboxUrl(); + } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 4ebcb57a2..b632bca98 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -13,11 +13,11 @@ class EventServiceProvider extends ServiceProvider * @var array */ protected $listen = [ - 'App\Events\Event' => [ - 'App\Listeners\EventListener', + 'Illuminate\Auth\Events\Login' => [ + 'App\Listeners\AuthLogin', ], - 'auth.login' => [ - 'App\Events\AuthLoginEvent', + 'Illuminate\Auth\Events\Failed' => [ + 'App\Listeners\LogFailedLogin', ], ];