diff --git a/app/Listeners/LogFailedLogin.php b/app/Listeners/LogFailedLogin.php new file mode 100644 index 0000000000..fc01eef52c --- /dev/null +++ b/app/Listeners/LogFailedLogin.php @@ -0,0 +1,46 @@ +insert( + [ + 'username' => $event->credentials['username'], + 'user_agent' => request()->header('User-Agent'), + 'remote_ip' => request()->ip(), + 'successful' => 0, + 'created_at' => $now; + ] + ); + } catch (\Exception $e) { + \Log::debug($e); + } + + } +} diff --git a/app/Listeners/LogSuccessfulLogin.php b/app/Listeners/LogSuccessfulLogin.php new file mode 100644 index 0000000000..077dfbec1d --- /dev/null +++ b/app/Listeners/LogSuccessfulLogin.php @@ -0,0 +1,49 @@ +insert( + [ + 'username' => $event->user->username, + 'user_agent' => request()->header('User-Agent'), + 'remote_ip' => request()->ip(), + 'successful' => 1, + 'created_at' => $now + ] + ); + } catch (\Exception $e) { + \Log::debug($e); + } + + + } +} diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index a182657e65..9d3e0f8a98 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -13,10 +13,16 @@ class EventServiceProvider extends ServiceProvider * @var array */ protected $listen = [ - 'App\Events\SomeEvent' => [ - 'App\Listeners\EventListener', - ], - ]; + + 'Illuminate\Auth\Events\Login' => [ + 'App\Listeners\LogSuccessfulLogin', + ], + + 'Illuminate\Auth\Events\Failed' => [ + 'App\Listeners\LogFailedLogin', + ], + ]; + /** * Register any events for your application. diff --git a/database/migrations/2018_07_17_005911_create_login_attempts_table.php b/database/migrations/2018_07_17_005911_create_login_attempts_table.php new file mode 100644 index 0000000000..9869f5c24d --- /dev/null +++ b/database/migrations/2018_07_17_005911_create_login_attempts_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('username')->nullable()->default(null); + $table->ipAddress('remote_ip')->nullable()->default(null); + $table->string('user_agent')->nullable()->default(null); + $table->boolean('successful')->nullable()->default(null); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('login_attempts'); + } +} diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php index 30355972fe..2dc8bb31ab 100644 --- a/resources/lang/en/admin/users/general.php +++ b/resources/lang/en/admin/users/general.php @@ -2,7 +2,8 @@ return array( - + 'activated_help_text' => 'This user can login', + 'activated_disabled_help_text' => 'You cannot edit activation status for your own account.', 'assets_user' => 'Assets assigned to :name', 'bulk_update_warn' => 'You are about to edit the properties of :user_count users. Please note that you cannot change your own user attributes using this form, and must make edits to your own user individually.', 'bulk_update_help' => 'This form allows you to update multiple users at once. Only fill in the fields you need to change. Any fields left blank will remain unchanged.', diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 114ea6b21d..483939e916 100755 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -51,7 +51,7 @@