|
21 | 21 | use Neos\Neos\Domain\Repository\DomainRepository; |
22 | 22 | use Neos\Neos\Domain\Repository\SiteRepository; |
23 | 23 | use Neos\Neos\Domain\Service\NodeTypeNameFactory; |
| 24 | +use Neos\Neos\Domain\Service\UserService; |
24 | 25 | use Neos\Neos\Domain\Service\WorkspaceService; |
25 | 26 | use Neos\Neos\FrontendRouting\NodeUriBuilderFactory; |
26 | 27 | use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; |
@@ -105,6 +106,12 @@ class BackendController extends ActionController |
105 | 106 | */ |
106 | 107 | protected $userProvider; |
107 | 108 |
|
| 109 | + /** |
| 110 | + * @Flow\Inject |
| 111 | + * @var UserService |
| 112 | + */ |
| 113 | + protected $userService; |
| 114 | + |
108 | 115 | /** |
109 | 116 | * @Flow\Inject |
110 | 117 | * @var InitialStateProviderInterface |
@@ -135,6 +142,11 @@ public function indexAction(string $node = null) |
135 | 142 | $contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId); |
136 | 143 |
|
137 | 144 | $nodeAddress = $node !== null ? NodeAddress::fromJsonString($node) : null; |
| 145 | + $user = $this->userService->getCurrentUser(); |
| 146 | + |
| 147 | + if ($user === null) { |
| 148 | + $this->redirectToUri($this->uriBuilder->uriFor('index', [], 'Login', 'Neos.Neos')); |
| 149 | + } |
138 | 150 |
|
139 | 151 | $this->workspaceService->createPersonalWorkspaceForUserIfMissing($siteDetectionResult->contentRepositoryId, $user); |
140 | 152 | $workspace = $this->workspaceService->getPersonalWorkspaceForUser($siteDetectionResult->contentRepositoryId, $user->getId()); |
@@ -170,6 +182,7 @@ public function indexAction(string $node = null) |
170 | 182 | $node = $subgraph->findNodeById($nodeAddress->aggregateId); |
171 | 183 | } |
172 | 184 |
|
| 185 | + // todo duplicate user logic see above $this->userService->getBackendUser() is never null here ... pass the user instead to the method? |
173 | 186 | $user = $this->userProvider->getUser(); |
174 | 187 | if (!$user) { |
175 | 188 | $this->redirectToUri($this->uriBuilder->uriFor('index', [], 'Login', 'Neos.Neos')); |
|
0 commit comments