Skip to content

Commit

Permalink
Applications: scopes are now strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasgarner committed Jul 20, 2021
1 parent bfe1584 commit a6508fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 20 additions & 2 deletions lib/Controller/Applications.php
Expand Up @@ -173,14 +173,32 @@ public function grid(Request $request, Response $response)
public function authorizeRequest(Request $request, Response $response)
{
// Pull authorize params from our session
if (!$authParams = $this->session->get('authParams')) {
/** @var AuthorizationRequest $authParams */
$authParams = $this->session->get('authParams');
if (!$authParams) {
throw new InvalidArgumentException(__('Authorisation Parameters missing from session.'), 'authParams');
}

// Process any scopes.
$scopes = [];
$authScopes = $authParams->getScopes();
if ($authScopes !== null) {
foreach ($authScopes as $scope) {
$this->getLog()->debug('Loading scope: ' . $scope->getIdentifier());
$scopes[] = $this->applicationScopeFactory->getById($scope->getIdentifier());
}
}

// `all` is the default scope
if (count($scopes) <= 0) {
$scopes[] = $this->applicationScopeFactory->getById('all');
}

// Get, show page
$this->getState()->template = 'applications-authorize-page';
$this->getState()->setData([
'authParams' => $authParams
'authParams' => $authParams,
'scopes' => $scopes
]);

return $this->render($request, $response);
Expand Down
6 changes: 3 additions & 3 deletions views/applications-authorize-page.twig
Expand Up @@ -28,12 +28,12 @@
<div class="widget-title">{% trans "Authorize Request" %}</div>
<div class="widget-body">
<h1>{{ authParams.client.getName() }}</h1>
<h5>{{ "would like access to the following scopes"|trans }} :</h5>
<h5>{{ "would like access to the following scopes"|trans }}:</h5>

<ul>
{% for scope in authParams.scopes %}
{% for scope in scopes %}
<li>
{{ scope.getIdentifier() }} : {{ scope.getDescription() }}
{{ scope.description }}
</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit a6508fa

Please sign in to comment.