Controller for the URL sync
@param $scope - directive scope
@param History
@param Clients
557421
function historyDirective($scope, History, Clients) {

        var ctrl = this;

        ctrl.visited = [];

        ctrl.utils = {};

        ctrl.utils.localUrl = function (path) {
            return [$scope.options.urls.local, path].join("");
        };

        ctrl.updateVisited = function (data) {
            ctrl.visited = data;
            $scope.$digest();
        };

        ctrl.sendAllTo = function (url) {
            url.success = true;
            Clients.sendAllTo(url.path);
            setTimeout(function () {
                url.success = false;
                $scope.$digest();
            }, 1000);
        };

        ctrl.removeVisited = function (item) {
            History.remove(item);
        };

        History.get().then(function (items) {
            ctrl.visited = items;
        });

        History.on("change", ctrl.updateVisited);

        $scope.$on("$destroy", function () {
            History.off(ctrl.updateVisited);
        });
    }
1283233
public function historyAction()
	{
		$client = \Aimeos\Client\Html::create( $this->getContext(), 'account/history' );
		return $this->getClientOutput( $client );
	}
836236
def compare(self, previous_scopes):
        
        for scope in self.scopes:
            if scope not in previous_scopes:
                raise OAuthInvalidError(
                    error="invalid_scope",
                    explanation="Invalid scope parameter in request")

        return True
444432
function LocationFactory($rootScope, $window) {
  const history = $window.history;
  const service = new StatemanagerLocation($window.location, $window.history);

  let lastUri = service.getUriString();
  $rootScope.$watch(() => {
    const newUri = service.getUriString();
    if (lastUri !== newUri) {
      $rootScope.$evalAsync(() => {
        lastUri = newUri;
        if (history !== undefined && history.replaceState !== undefined) {
          replaceState(history, newUri);
        }
        $rootScope.$broadcast('ngeoLocationChange');
      });
    }
  });

  return service;
}
1082019
protected function validateScope(ClientInterface $client, array $scopes = null): array
    {
        if (empty($scopes) === true) {
            $clientScopes = $client->getScopeIdentifiers();
            $isModified   = $clientScopes !== $scopes;

            return $client->isUseDefaultScopesOnEmptyRequest() === true ?
                [true, $clientScopes, $isModified] : [false, $scopes, false];
        }

        $extraScopes    = array_diff($scopes, $client->getScopeIdentifiers());
        $hasExtraScopes = count($extraScopes) > 0;
        $isInvalidScope = $hasExtraScopes === true && $client->isScopeExcessAllowed() === false;

        return $isInvalidScope === true ? [false, $scopes, false] : [true, $scopes, false];
    }
1135964
public function update(Queries\IScope $scope)
    {
        if ($this->scope === $scope) {
            return $this;
        }

        return new self($scope);
    }
601172
function reloadSites() {
    function reload() {
      sites.get()
      .then(function(sites) {
        $scope.ui.sites = sites;
      });
    }
    /*
     * Reload sites mutliple times, because sometimes updates to list of sites
     * aren't ready immediately.
     */
    // Reload sites immediately.
    reload();
    // Reload sites again after 5 seconds.
    setTimeout(reload, 1000 * 5);
    // Reload sites again after 15 seconds.
    setTimeout(reload, 1000 * 15);
  }
960676
public function override(array $scope)
    {
        $this->checkPermissions(null, self::ACTION_OVERRIDE);
        $this->scope = $scope;
    }
1115942
public function service($provider, $url = null, $scope = null)
	{
		$info = Config::get('laravel-social::providers.' . strtolower($provider));
		
		if (empty($info) || !is_array($info)) {
			throw new Exception('Missing configuration details for Social service: ' . $provider);
		}
		
		$client_id     = array_get($info, 'client_id');
		$client_secret = array_get($info, 'client_secret');
		$scope         = is_null($scope) ? array_get($info, 'scope') : $scope;
		
		if (empty($client_id) || empty($client_secret)) {
			throw new Exception('Missing client id/secret for Social service: ' . $provider);
		}
		
		return $this->factory->createService(
			ucfirst($provider),
			new Credentials($client_id, $client_secret, $url ?: URL::current()),
			$this->storage,
			$scope
		);
	}
352058
function (path, params) {
  let existInHistory = -1
  if (this.launcherMode != 'normal' && this.history.length > 0) {
    for (let i=this.history.length-1; i>=0; i--) {
      if (path == this.history[i][1] && (!this.compareParam || (this.compareParam && (!params && !this.history[i][2] || equal(params, this.history[i][2]))))) {
        existInHistory = i
        break
      }
      if (this.launcherMode === 'singleTop') {
        break
      }
    }
  }
  if (existInHistory < 0) {
    this.rid++
    let historyId = this.rid + '_' + (+new Date)
    this.history.push([historyId, path, params && Object.keys(params).length > 0 ? params : null])
  } else {
    this.finishedHistoryIds.push('_')
    this.history = this.history.slice(0, existInHistory + 1)
    let currentEndRoute = this.currentRoute.slice(-1)[0]
    this.history.slice(-1)[0].push({reuse: currentEndRoute && currentEndRoute[1].meta && currentEndRoute[1].meta.reuse})
  }
  if (this.history.length > this.maxHistorySize) {
    this.finishedHistoryIds.push('_')
    this.history = this.history.slice(0-this.maxHistorySize)
  }
}
1082569
public function hasScope($scope)
    {
        if (is_array($scope)) {
            foreach ($scope as $s) {
                if ($this->hasScope($s) === false) {
                    return false;
                }
            }

            return true;
        }

        return $this->getAccessToken()->hasScope($scope);
    }
669605
public static function syncRoutes(Connection $connection, array $routes, \Closure $callback)
    {
        $scopes = [];
        $maxId  = (int) $connection->fetchColumn('SELECT MAX(id) AS max_id FROM fusio_routes');

        foreach ($routes as $row) {
            $route = $connection->fetchAssoc('SELECT id, status, priority, methods, controller FROM fusio_routes WHERE path = :path', [
                'path' => $row['path']
            ]);

            if (empty($route)) {
                // the route does not exist so create it
                self::insertRow('fusio_routes', $row, $callback);

                $maxId++;

                $scopeId = NewInstallation::getScopeIdFromPath($row['path']);
                if ($scopeId !== null) {
                    $scopes[] = [
                        'scope_id' => $scopeId,
                        'route_id' => $maxId,
                        'allow'    => 1,
                        'methods'  => 'GET|POST|PUT|PATCH|DELETE',
                    ];
                }
            } else {
                // the route exists check whether something has changed
                $columns = ['status', 'priority', 'controller'];

                self::updateRow('fusio_routes', $row, $route, $columns, $callback);
            }
        }

        if (!empty($scopes)) {
            // add new routes to scopes
            foreach ($scopes as $row) {
                self::insertRow('fusio_scope_routes', $row, $callback);
            }
        }
    }
405729
private function addScopeAndRedirectUris(Client $client): void
    {
        $client->setScopeIdentifiers($this->readScopeIdentifiers($client->getIdentifier()));
        $client->setRedirectUriStrings($this->readRedirectUriStrings($client->getIdentifier()));
    }
974903
function createDefaultHandler (history) {
  return function (context, runMiddleware) {
    runMiddleware(context, function (err, redirect) {
      if (err) {
        console.error(`${context.uri} -> ${err.message}`, err);
      } else if (redirect) {
        history.replace(redirect);
      }
    });
  }
}
454469
function setScope($scope)
    {
        $scopes = array_merge($this->getScopes(), array( (string) $scope) );
        $this->setScopes($scopes);
        return $this;
    }
523683
function ($scope) {
    this.options = { headers: {} };
    if ($scope && $scope.constructor == String) {
        this.options.uri = $scope;
        $scope = {};
    }
    this.data = $scope || {};
    this.jsonArray = [];
    this.posts = {};
    this.cookies = {};
    this.headers = {};
    this.vars = {}; //url query variables
}
1325766
function(url) {
      if (!isSupportHistoryAPI && ('' + url).indexOf('#') === 0) {
        changeState(null, url);
      } else {
        windowLocation.assign(url);
      }
    }