예제 #1
0
파일: Scope.php 프로젝트: apioo/fusio-impl
 /**
  * Returns all scope names which are valid for the app and the user. The
  * scopes are a comma seperated list. All scopes which are listed in the
  * $exclude array are excluded
  *
  * @param integer $appId
  * @param integer $userId
  * @param string $scopes
  * @param array $exclude
  * @return array
  */
 public function getValidScopes($appId, $userId, $scopes, array $exclude = array())
 {
     $scopes = explode(',', $scopes);
     $scopes = $this->appScopeTable->getValidScopes($appId, $scopes, $exclude);
     $scopes = $this->userScopeTable->getValidScopes($userId, $scopes, $exclude);
     return $scopes;
 }
예제 #2
0
파일: User.php 프로젝트: apioo/fusio-impl
 protected function insertScopes($userId, $scopes)
 {
     if (!empty($scopes) && is_array($scopes)) {
         $scopes = $this->scopeTable->getByNames($scopes);
         foreach ($scopes as $scope) {
             $this->userScopeTable->create(array('userId' => $userId, 'scopeId' => $scope['id']));
         }
     }
 }
예제 #3
0
 protected function getValidUserScopes($userId, $scopes)
 {
     if (empty($scopes)) {
         return [];
     }
     $userScopes = $this->userScopeTable->getByUserId($userId);
     $scopes = $this->scopeTable->getByNames($scopes);
     // check that the user can assign only the scopes which are also
     // assigned to the user account
     $scopes = array_filter($scopes, function ($scope) use($userScopes) {
         foreach ($userScopes as $userScope) {
             if ($userScope['scopeId'] == $scope['id']) {
                 return true;
             }
         }
         return false;
     });
     return array_map(function ($scope) {
         return $scope['name'];
     }, $scopes);
 }