Skip to content

Commit 6ab9419

Browse files
authored
Merge pull request #75 from rappasoft/develop
v3.0.0
2 parents 9cba918 + 3938d57 commit 6ab9419

File tree

7 files changed

+28
-18
lines changed

7 files changed

+28
-18
lines changed

.github/workflows/run-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
fail-fast: true
1414
matrix:
1515
os: [ubuntu-latest, windows-latest]
16-
php: [8.0, 8.1]
17-
laravel: [9.*]
16+
php: [8.1]
17+
laravel: [10.*]
1818
stability: [prefer-lowest, prefer-stable]
1919
include:
20-
- laravel: 9.*
21-
testbench: 7.0
20+
- laravel: 10.*
21+
testbench: 8.0
2222

2323
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2424

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
### 3.0.0 - 2023-02-23
6+
7+
- Laravel 10 Support - https://github.com/rappasoft/laravel-authentication-log/pull/70
8+
- Use null safe/chaining operator - https://github.com/rappasoft/laravel-authentication-log/pull/57
9+
- Optimize Other Devices Logout Listener - https://github.com/rappasoft/laravel-authentication-log/pull/52
10+
511
### 2.0.0 - 2022-02-19
612

713
### Added

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ See the [documentation](https://rappasoft.com/docs/laravel-authentication-log) f
1717
:---------|:------------------
1818
8.x | 1.x
1919
9.x | 2.x
20+
10.x | 3.x
21+
22+
## Installation
23+
24+
```bash
25+
composer require rappasoft/laravel-authentication-log
26+
```
2027

2128
## Testing
2229

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^8.0",
20-
"illuminate/contracts": "^9.0",
19+
"php": "^8.1",
20+
"illuminate/contracts": "^10.0",
2121
"spatie/laravel-package-tools": "^1.4.3"
2222
},
2323
"require-dev": {

src/Listeners/OtherDeviceLogoutListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function handle($event): void
3535
]);
3636
}
3737

38-
foreach ($user->authentications()->whereLoginSuccessful(true)->get() as $log) {
38+
foreach ($user->authentications()->whereLoginSuccessful(true)->whereNull('logout_at')->get() as $log) {
3939
if ($log->id !== $authenticationLog->id) {
4040
$log->update([
4141
'cleared_by_user' => true,

src/Models/AuthenticationLog.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ class AuthenticationLog extends Model
2525
'cleared_by_user' => 'boolean',
2626
'location' => 'array',
2727
'login_successful' => 'boolean',
28-
];
29-
30-
protected $dates = [
31-
'login_at',
32-
'logout_at',
28+
'login_at' => 'datetime',
29+
'logout_at' => 'datetime',
3330
];
3431

3532
public function __construct(array $attributes = [])

src/Traits/AuthenticationLoggable.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@ public function notifyAuthenticationLogVia(): array
2323

2424
public function lastLoginAt()
2525
{
26-
return optional($this->authentications()->first())->login_at;
26+
return $this->authentications()->first()?->login_at;
2727
}
2828

2929
public function lastSuccessfulLoginAt()
3030
{
31-
return optional($this->authentications()->whereLoginSuccessful(true)->first())->login_at;
31+
return $this->authentications()->whereLoginSuccessful(true)->first()?->login_at;
3232
}
3333

3434
public function lastLoginIp()
3535
{
36-
return optional($this->authentications()->first())->ip_address;
36+
return $this->authentications()->first()?->ip_address;
3737
}
3838

3939
public function lastSuccessfulLoginIp()
4040
{
41-
return optional($this->authentications()->whereLoginSuccessful(true)->first())->ip_address;
41+
return $this->authentications()->whereLoginSuccessful(true)->first()?->ip_address;
4242
}
4343

4444
public function previousLoginAt()
4545
{
46-
return optional($this->authentications()->skip(1)->first())->login_at;
46+
return $this->authentications()->skip(1)->first()?->login_at;
4747
}
4848

4949
public function previousLoginIp()
5050
{
51-
return optional($this->authentications()->skip(1)->first())->ip_address;
51+
return $this->authentications()->skip(1)->first()?->ip_address;
5252
}
5353
}

0 commit comments

Comments
 (0)