mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
chore: added duplicate scope check in constructor
This commit is contained in:
parent
563ea1363c
commit
1f1e4e0def
1 changed files with 9 additions and 7 deletions
|
|
@ -27,7 +27,7 @@ abstract class OAuth
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $userScopes;
|
protected $scopes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OAuth constructor.
|
* OAuth constructor.
|
||||||
|
|
@ -36,15 +36,17 @@ abstract class OAuth
|
||||||
* @param string $appSecret
|
* @param string $appSecret
|
||||||
* @param string $callback
|
* @param string $callback
|
||||||
* @param array $state
|
* @param array $state
|
||||||
* @param array $userScopes
|
* @param array $scopes
|
||||||
*/
|
*/
|
||||||
public function __construct(string $appId, string $appSecret, string $callback, $state = [], $userScopes = [])
|
public function __construct(string $appId, string $appSecret, string $callback, $state = [], $scopes = [])
|
||||||
{
|
{
|
||||||
$this->appID = $appId;
|
$this->appID = $appId;
|
||||||
$this->appSecret = $appSecret;
|
$this->appSecret = $appSecret;
|
||||||
$this->callback = $callback;
|
$this->callback = $callback;
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
$this->userScopes = $userScopes;
|
foreach($scopes as $scope) {
|
||||||
|
$this->addScope($scope);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,8 +94,8 @@ abstract class OAuth
|
||||||
*/
|
*/
|
||||||
protected function addScope(string $scope){
|
protected function addScope(string $scope){
|
||||||
// Add a scope to the scopes array if it isn't already present
|
// Add a scope to the scopes array if it isn't already present
|
||||||
if (!in_array($scope, $this->userScopes)){
|
if (!in_array($scope, $this->scopes)){
|
||||||
$this->userScopes[] = $scope;
|
$this->scopes[] = $scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +103,7 @@ abstract class OAuth
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getScopes(){
|
protected function getScopes(){
|
||||||
return $this->userScopes;
|
return $this->scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue