Skip to content

Commit

Permalink
Merge pull request #25 from rappasoft/develop
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
rappasoft authored Dec 2, 2021
2 parents 945f0f1 + 88c05b9 commit b8a5d24
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 8 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to `Laravel Authentication Log` will be documented in this file.

### 1.2.1 - 2021-12-02

### Added

- Added latestAuthentication relationship - https://github.com/rappasoft/laravel-authentication-log/pull/24

### Changed

- Fixed issue with PHP 7.4 - https://github.com/rappasoft/laravel-authentication-log/pull/22

### 1.2.0 - 2021-11-21

### Added
Expand Down
8 changes: 4 additions & 4 deletions src/LaravelAuthenticationLogServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function configurePackage(Package $package): void
->hasCommand(PurgeAuthenticationLogCommand::class);

$events = $this->app->make(Dispatcher::class);
$events->listen(config('authentication-log.events.login') ?? Login::class, LoginListener::class);
$events->listen(config('authentication-log.events.failed') ?? Failed::class, FailedLoginListener::class);
$events->listen(config('authentication-log.events.logout') ?? Logout::class, LogoutListener::class);
$events->listen(config('authentication-log.events.other-device-logout') ?? OtherDeviceLogout::class, OtherDeviceLogoutListener::class);
$events->listen(config('authentication-log.events.login', Login::class), LoginListener::class);
$events->listen(config('authentication-log.events.failed', Failed::class), FailedLoginListener::class);
$events->listen(config('authentication-log.events.logout', Logout::class), LogoutListener::class);
$events->listen(config('authentication-log.events.other-device-logout', OtherDeviceLogout::class), OtherDeviceLogoutListener::class);
}
}
3 changes: 2 additions & 1 deletion src/Listeners/FailedLoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function __construct(Request $request)

public function handle($event): void
{
if (! $event instanceof (config('authentication-log.events.failed') ?? Failed::class)) {
$listener = config('authentication-log.events.failed', Failed::class);
if (! $event instanceof $listener) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Listeners/LoginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function __construct(Request $request)

public function handle($event): void
{
if (! $event instanceof (config('authentication-log.events.login') ?? Login::class)) {
$listener = config('authentication-log.events.login', Login::class);
if (! $event instanceof $listener) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Listeners/LogoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function __construct(Request $request)

public function handle($event): void
{
if (! $event instanceof (config('authentication-log.events.logout') ?? Logout::class)) {
$listener = config('authentication-log.events.logout', Logout::class);
if (! $event instanceof $listener) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Listeners/OtherDeviceLogoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function __construct(Request $request)

public function handle($event): void
{
if (! $event instanceof (config('authentication-log.events.other-device-logout') ?? OtherDeviceLogout::class)) {
$listener = config('authentication-log.events.other-device-logout', OtherDeviceLogout::class);
if (! $event instanceof $listener) {
return;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Traits/AuthenticationLoggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public function authentications()
return $this->morphMany(AuthenticationLog::class, 'authenticatable')->latest('login_at');
}

public function latestAuthentication()
{
return $this->morphOne(AuthenticationLog::class, 'authenticatable')->latestOfMany('login_at');
}

public function notifyAuthenticationLogVia(): array
{
return ['mail'];
Expand Down

0 comments on commit b8a5d24

Please sign in to comment.