File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ class Authenticate extends IlluminateAuthenticate
99{
1010 public function handle ($ request , Closure $ next , ...$ guards )
1111 {
12+ if ($ request ->has ('api_token ' ) && !$ request ->headers ->has ('Authorization ' )) {
13+ $ request ->headers ->set ('Authorization ' , 'Bearer ' . $ request ->api_token );
14+ }
15+
1216 $ this ->authenticate ($ request , $ guards );
1317
1418 if (!$ request ->is ('api/* ' ) && $ request ->user ()->isSystemUser ()) {
Original file line number Diff line number Diff line change @@ -44,6 +44,19 @@ public function test_links_feed(): void
4444 $ response ->assertOk ()->assertSee ($ link ->url )->assertDontSee ($ otherLink ->url );
4545 }
4646
47+ public function test_links_feed_with_auth_as_query_param (): void
48+ {
49+ $ link = Link::factory ()->create ();
50+
51+ $ otherUser = User::factory ()->create ();
52+ $ otherLink = Link::factory ()->for ($ otherUser )->create (['visibility ' => ModelAttribute::VISIBILITY_PRIVATE ]);
53+
54+ $ token = $ this ->user ->createToken ('test ' , [ApiToken::ABILITY_USER_ACCESS ])->plainTextToken ;
55+ $ response = $ this ->get ('links/feed?api_token= ' . $ token );
56+
57+ $ response ->assertOk ()->assertSee ($ link ->url )->assertDontSee ($ otherLink ->url );
58+ }
59+
4760 public function test_lists_feed (): void
4861 {
4962 $ list = LinkList::factory ()->create ();
You can’t perform that action at this time.
0 commit comments