Merge pull request #58440 from nextcloud/backport/58144/stable33

[stable33] Fix/more missing userid cases
This commit is contained in:
Andy Scherzinger 2026-02-20 23:27:03 +01:00 committed by GitHub
commit 4308fab27d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -19,7 +19,7 @@ class UserIdHeaderPlugin extends \Sabre\DAV\ServerPlugin {
}
public function initialize(\Sabre\DAV\Server $server): void {
$server->on('afterMethod:*', [$this, 'afterMethod']);
$server->on('beforeMethod:*', [$this, 'beforeMethod']);
}
/**
@ -28,7 +28,7 @@ class UserIdHeaderPlugin extends \Sabre\DAV\ServerPlugin {
* @param RequestInterface $request request
* @param ResponseInterface $response response
*/
public function afterMethod(RequestInterface $request, ResponseInterface $response): void {
public function beforeMethod(RequestInterface $request, ResponseInterface $response): void {
if ($user = $this->userSession->getUser()) {
$response->setHeader('X-User-Id', $user->getUID());
}

View file

@ -1190,7 +1190,9 @@ class OC {
// Redirect to the default app or login only as an entry point
if ($requestPath === '') {
// Someone is logged in
if (Server::get(IUserSession::class)->isLoggedIn()) {
$userSession = Server::get(IUserSession::class);
if ($userSession->isLoggedIn()) {
header('X-User-Id: ' . $userSession->getUser()?->getUID());
header('Location: ' . Server::get(IURLGenerator::class)->linkToDefaultPageUrl());
} else {
// Not handled and not logged in