mirror of
https://github.com/appwrite/appwrite
synced 2026-05-15 13:08:31 +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
|
||||
*/
|
||||
protected $userScopes;
|
||||
protected $scopes;
|
||||
|
||||
/**
|
||||
* OAuth constructor.
|
||||
|
|
@ -36,15 +36,17 @@ abstract class OAuth
|
|||
* @param string $appSecret
|
||||
* @param string $callback
|
||||
* @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->appSecret = $appSecret;
|
||||
$this->callback = $callback;
|
||||
$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){
|
||||
// Add a scope to the scopes array if it isn't already present
|
||||
if (!in_array($scope, $this->userScopes)){
|
||||
$this->userScopes[] = $scope;
|
||||
if (!in_array($scope, $this->scopes)){
|
||||
$this->scopes[] = $scope;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +103,7 @@ abstract class OAuth
|
|||
* @return array
|
||||
*/
|
||||
protected function getScopes(){
|
||||
return $this->userScopes;
|
||||
return $this->scopes;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue