Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: (9.0) User Workspace is null if first login to the site happens via "/neos/switch/to/..." #4401

Closed
grebaldi opened this issue Jul 12, 2023 · 2 comments · Fixed by #5299
Assignees

Comments

@grebaldi
Copy link
Contributor

grebaldi commented Jul 12, 2023

I found theEditorContentStreamZooKeeper to be responsible for creating user workspaces upon authentication when they do not exist yet.

For this purpose the relayEditorAuthentication method of EditorContentStreamZookeeper is registered as a signal handler for AuthenticationProviderManager::authenticatedToken:

$dispatcher->connect(
AuthenticationProviderManager::class,
'authenticatedToken',
EditorContentStreamZookeeper::class,
'relayEditorAuthentication'
);

If a user logs in via the form at /neos/login, this mechanism works perfectly.

In a multi-site setup however, the user may log in via /neos/login at site-a and then switches to site-b via the main menu by clicking on the link that leads to /neos/switch/to/site-b.

EditorContentStreamZooKeeper::relayEditorAuthentication does not capture this, so if the user doesn't have a user workspace at site-b already, it won't be created automatically in this case. The user is now trapped in an infinite redirect loop due to:
https://github.com/neos/neos-ui/blob/283a073b4b49ea20742067ef2d567516cabd9534/Classes/Controller/BackendController.php#L150-L156

I don't know what exactly needs to be fixed here. I looks to me as if LoginController::tokenLoginAction shouldn't cirumvent the AuthenticationProviderManager::authenticatedToken signal. But I have to admit that I have no idea what is supposed to happen here 😅

Related: #4590

@mhsdesign
Copy link
Member

mhsdesign commented Nov 9, 2023

Same issue is when someone logged into neos before there was a site, and if afterwards a site will be created. The session is already authenticated so the zookeeper doesnt create a user workspace.

Currently the backend controller redirects to the login page https://github.com/neos/neos-ui/blob/369d27ab664d985b4f352eaabdc3b993719faa9c/Classes/Controller/BackendController.php#L155 in the hope that a user workspace will be created but, in reality we just crated a nice endless redirect loop.

To fix this i implemented the following instead of the redirect:

if (!$workspace) {
    // if a neos login session was active before the site was imported the EditorContentStreamZookeper was not able to create a user workspace. In that case we will do this here:
    $baseWorkspace = $contentRepository->getWorkspaceFinder()->findOneByName(WorkspaceName::forLive());
    if (!$baseWorkspace) {
        throw new NoHomepageException();
    }
    $editorsNewContentStreamId = ContentStreamId::create();
    $contentRepository->handle(
        CreateWorkspace::create(
            $workspaceName,
            $baseWorkspace->workspaceName,
            new WorkspaceTitle((string) $user->getName()),
            new WorkspaceDescription(''),
            $editorsNewContentStreamId,
            UserId::fromString($this->persistenceManager->getIdentifierByObject($user))
        )
    )->block();
    $workspace = $contentRepository->getWorkspaceFinder()->findOneByName(
        $workspaceName
    );
}

but what speaks against creating a workspace in the neos ui backend controller in general and remove the zookeeper?


tltr:

i want to create a user workspace only on demand directly in BackendController::indexAction is there a known flaw to this?
The zookeeper would only take care of removing workspaces if a user is deleted.

@ahaeslich ahaeslich moved this from Todo to Prioritized 🔥 in Neos 9.0 Release Board Apr 10, 2024
@bwaidelich
Copy link
Member

This will hopefully resolved with #5146

@mhsdesign mhsdesign self-assigned this Oct 17, 2024
mficzel added a commit to mficzel/neos-development-collection that referenced this issue Oct 21, 2024
… user with id" after `cr:prune` and site switching

- After `cr:prune` all sessions are destroyed to enforce a fresh login. The login will then create the missing personal workspace if needed.
- During site:switch it is checked wether the new site has a personal workspace for the current user and create this if missing

Resolves: neos#4566
Relates: neos#4401
@github-project-automation github-project-automation bot moved this from In Progress 🚧 to Done ✅ in Neos 9.0 Release Board Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
4 participants