File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,14 @@ class MagiclinkMiddleware
11
11
{
12
12
public function handle (Request $ request , Closure $ next )
13
13
{
14
- if ($ request ->method () === 'HEAD ' ) {
15
- return $ next ($ request );
16
- }
17
-
18
14
$ token = (string ) $ request ->route ('token ' );
19
15
20
16
$ magicLink = MagicLink::getValidMagicLinkByToken ($ token );
21
17
18
+ if ($ request ->method () === 'HEAD ' ) {
19
+ return response ()->noContent ($ magicLink ? 200 : 404 );
20
+ }
21
+
22
22
if (! $ magicLink ) {
23
23
return $ this ->badResponse ();
24
24
}
Original file line number Diff line number Diff line change @@ -73,4 +73,14 @@ public function test_http_urlencode_legacy()
73
73
->assertStatus (200 )
74
74
->assertSeeText ('private content ' );
75
75
}
76
+
77
+ public function test_http_head_request_without_valid_magiclink ()
78
+ {
79
+ $ magiclink = MagicLink::create (new ResponseAction (function () {
80
+ return 'private content ' ;
81
+ }));
82
+
83
+ $ this ->head ($ magiclink ->url . '-bad ' )
84
+ ->assertStatus (404 );
85
+ }
76
86
}
You can’t perform that action at this time.
0 commit comments