Skip to content

Commit

Permalink
Account for current user deauthorizing themself (fix #2034)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Mar 16, 2023
1 parent ce9d045 commit 8ba8610
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions application/src/Controller/SiteAdmin/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ public function resourcesAction()
public function usersAction()
{
$site = $this->currentSite();
if (!$site->userIsAllowed('update')) {
throw new Exception\PermissionDeniedException(
'User does not have permission to edit site theme settings'
);
}
$form = $this->getForm(Form::class)->setAttribute('id', 'site-form');

if ($this->getRequest()->isPost()) {
Expand All @@ -298,6 +303,11 @@ public function usersAction()
$response = $this->api($form)->update('sites', $site->id(), $formData, [], ['isPartial' => true]);
if ($response) {
$this->messenger()->addSuccess('User permissions successfully updated'); // @translate
if (!$site->userIsAllowed('update')) {
// The current user may have deauthorized themself during
// this request. Redirect to pages.
return $this->redirect()->toRoute('admin/site/slug/page', [], true);
}
return $this->redirect()->refresh();
}
} else {
Expand Down

0 comments on commit 8ba8610

Please sign in to comment.