diff --git a/src/Traits/HandlesAuthentication.php b/src/Traits/HandlesAuthentication.php index 8a59c6b..1fb1427 100644 --- a/src/Traits/HandlesAuthentication.php +++ b/src/Traits/HandlesAuthentication.php @@ -53,7 +53,7 @@ public function getRedirect(?string $redirectUrl = null, array $scopes = []): st throw new \InvalidArgumentException('A valid redirect URL is required'); } - $scopes = array_merge($this->config['scopes'] ?? [], [ + $scopes = array_merge($this->config['scopes'] ?? [], $scopes, [ 'email', 'public_profile', ]); diff --git a/tests/FacebookTest.php b/tests/FacebookTest.php index 5726a09..c5a5d0e 100644 --- a/tests/FacebookTest.php +++ b/tests/FacebookTest.php @@ -72,6 +72,11 @@ $this->assertStringContainsStringIgnoringCase('scope='.urlencode('email,public_profile'), $redirect); }); +it('merges scopes passed when fetching redirect URLs', function () { + $redirect = $this->getFacebookMock()->getRedirect(null, ['publish_actions']); + $this->assertStringContainsStringIgnoringCase('scope='.urlencode('publish_actions,email,public_profile'), $redirect); +}); + it('builds replaces duplicate scopes with defaults', function () { $redirect = $this->getFacebookMock(['scopes' => ['email', 'public_profile']])->getRedirect(); $this->assertStringContainsStringIgnoringCase('scope='.urlencode('email,public_profile'), $redirect);