From 3561ad99ffc90df2a1b0006ef935fe89d8e1ca90 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 5 Mar 2018 14:10:08 +0100 Subject: [PATCH] fix login embed and validate webspace in community admin --- Admin/CommunityAdmin.php | 30 +++++++++++++++++++-- Resources/views/Login/login-embed.html.twig | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Admin/CommunityAdmin.php b/Admin/CommunityAdmin.php index b5098093..8cef111e 100644 --- a/Admin/CommunityAdmin.php +++ b/Admin/CommunityAdmin.php @@ -84,9 +84,35 @@ public function getSecurityContexts() { $systems = []; + $webspaceCollection = $this->webspaceManager->getWebspaceCollection(); + + $webspaceKeys = array_keys($webspaceCollection->getWebspaces()); + foreach ($this->webspacesConfiguration as $webspaceKey => $webspaceConfig) { - $webspace = $this->webspaceManager->getWebspaceCollection()->getWebspace($webspaceKey); - $system = $webspace->getSecurity()->getSystem(); + $webspace = $webspaceCollection->getWebspace($webspaceKey); + + if (!$webspace) { + throw new \InvalidArgumentException( + sprintf( + 'Webspace "%s" not found for "sulu_community" expected one of %s.', + $webspaceKey, + '"' . implode('", "', $webspaceKeys) . '"' + ) + ); + } + + $security = $webspace->getSecurity(); + + if (!$security) { + throw new \InvalidArgumentException( + sprintf( + 'Missing "Website" configuration in webspace "%s" for "sulu_community".', + $webspaceKey + ) + ); + } + + $system = $security->getSystem(); $systems[$system] = []; } diff --git a/Resources/views/Login/login-embed.html.twig b/Resources/views/Login/login-embed.html.twig index c1fb8040..6aea3053 100644 --- a/Resources/views/Login/login-embed.html.twig +++ b/Resources/views/Login/login-embed.html.twig @@ -1,4 +1,4 @@ -{{% if maintenanceMode %} +{% if maintenanceMode %} {# Show nothing in maintenance mode #} {% else %} {% if app.user %}