Skip to content

Commit b5f319c

Browse files
authored
Merge pull request #29 from benlumley/master
Fix for null argument to lifetime not being considered.
2 parents a1d0e9a + 7bcf9b0 commit b5f319c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/MagicLink.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ public static function getValidMagicLinkByToken($token)
128128

129129
return self::where('id', $tokenId)
130130
->where('token', $tokenSecret)
131-
->where('available_at', '>=', Carbon::now())
131+
->where(function ($query) {
132+
$query
133+
->whereNull('available_at')
134+
->orWhere('available_at', '>=', Carbon::now());
135+
})
132136
->where(function ($query) {
133137
$query
134138
->whereNull('max_visits')

tests/MagicLinkTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public function test_fails_when_date_is_expired()
5757
->assertStatus(403);
5858
}
5959

60+
public function test_ok_when_date_is_null()
61+
{
62+
$magiclink = MagicLink::create(new LoginAction(User::first()), null);
63+
64+
$this->get($magiclink->url)
65+
->assertStatus(302);
66+
}
67+
6068
public function test_fail_when_max_visits_completed()
6169
{
6270
$magiclink = MagicLink::create(new LoginAction(User::first()));

0 commit comments

Comments
 (0)