From ed2122dce14cab7f49d73ade43b0ef6072787772 Mon Sep 17 00:00:00 2001 From: Lindsay Snider Date: Tue, 18 Jan 2022 16:35:43 -0500 Subject: [PATCH 1/5] add/set approvedScopes in User --- src/Two/AbstractProvider.php | 3 ++- src/Two/User.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Two/AbstractProvider.php b/src/Two/AbstractProvider.php index 06f00e5a..2be09587 100644 --- a/src/Two/AbstractProvider.php +++ b/src/Two/AbstractProvider.php @@ -244,7 +244,8 @@ public function user() return $this->user->setToken($token) ->setRefreshToken(Arr::get($response, 'refresh_token')) - ->setExpiresIn(Arr::get($response, 'expires_in')); + ->setExpiresIn(Arr::get($response, 'expires_in')) + ->setApprovedScopes(Arr::get($response, 'scope')); } /** diff --git a/src/Two/User.php b/src/Two/User.php index 0f31b640..8c805542 100644 --- a/src/Two/User.php +++ b/src/Two/User.php @@ -27,6 +27,12 @@ class User extends AbstractUser */ public $expiresIn; + /** + * The scopes the users authorized. These may be a subset of the requested scopes + * @var + */ + public $approvedScopes; + /** * Set the token on the user. * @@ -65,4 +71,15 @@ public function setExpiresIn($expiresIn) return $this; } + + /** + * @param string $approvedScopes + * @return $this + */ + public function setApprovedScopes($approvedScopes) + { + $this->approvedScopes = $approvedScopes; + + return $this; + } } From c290d16af577a2d0d390cf091913d32cc7135797 Mon Sep 17 00:00:00 2001 From: Lindsay Snider Date: Tue, 18 Jan 2022 16:38:18 -0500 Subject: [PATCH 2/5] lint --- src/Two/User.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Two/User.php b/src/Two/User.php index 8c805542..2d44788f 100644 --- a/src/Two/User.php +++ b/src/Two/User.php @@ -29,7 +29,8 @@ class User extends AbstractUser /** * The scopes the users authorized. These may be a subset of the requested scopes - * @var + * + * @var string */ public $approvedScopes; From 57d311c268441a727cd71f93378eff68a4fe8d34 Mon Sep 17 00:00:00 2001 From: Lindsay Snider Date: Tue, 18 Jan 2022 16:40:11 -0500 Subject: [PATCH 3/5] lint --- src/Two/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Two/User.php b/src/Two/User.php index 2d44788f..bf05bb0b 100644 --- a/src/Two/User.php +++ b/src/Two/User.php @@ -28,7 +28,7 @@ class User extends AbstractUser public $expiresIn; /** - * The scopes the users authorized. These may be a subset of the requested scopes + * The scopes the users authorized. These may be a subset of the requested scopes. * * @var string */ From b765f2a11694913219612cbba3b9d3a400d461b8 Mon Sep 17 00:00:00 2001 From: Lindsay Snider Date: Tue, 18 Jan 2022 16:59:10 -0500 Subject: [PATCH 4/5] switch approved scopes to an array --- src/Two/AbstractProvider.php | 2 +- src/Two/User.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Two/AbstractProvider.php b/src/Two/AbstractProvider.php index 2be09587..9a22d81b 100644 --- a/src/Two/AbstractProvider.php +++ b/src/Two/AbstractProvider.php @@ -245,7 +245,7 @@ public function user() return $this->user->setToken($token) ->setRefreshToken(Arr::get($response, 'refresh_token')) ->setExpiresIn(Arr::get($response, 'expires_in')) - ->setApprovedScopes(Arr::get($response, 'scope')); + ->setApprovedScopes(explode(' ', Arr::get($response, 'scope', ''))); } /** diff --git a/src/Two/User.php b/src/Two/User.php index bf05bb0b..b1087cc6 100644 --- a/src/Two/User.php +++ b/src/Two/User.php @@ -30,7 +30,7 @@ class User extends AbstractUser /** * The scopes the users authorized. These may be a subset of the requested scopes. * - * @var string + * @var array */ public $approvedScopes; @@ -74,7 +74,7 @@ public function setExpiresIn($expiresIn) } /** - * @param string $approvedScopes + * @param array $approvedScopes * @return $this */ public function setApprovedScopes($approvedScopes) From 288551565d41d076246b0a989694fbcd3d471706 Mon Sep 17 00:00:00 2001 From: Lindsay Snider Date: Tue, 18 Jan 2022 18:14:16 -0500 Subject: [PATCH 5/5] use the scopeSeparator --- src/Two/AbstractProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Two/AbstractProvider.php b/src/Two/AbstractProvider.php index 9a22d81b..e928b4f1 100644 --- a/src/Two/AbstractProvider.php +++ b/src/Two/AbstractProvider.php @@ -245,7 +245,7 @@ public function user() return $this->user->setToken($token) ->setRefreshToken(Arr::get($response, 'refresh_token')) ->setExpiresIn(Arr::get($response, 'expires_in')) - ->setApprovedScopes(explode(' ', Arr::get($response, 'scope', ''))); + ->setApprovedScopes(explode($this->scopeSeparator, Arr::get($response, 'scope', ''))); } /**