Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/UserIdHeaderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
}

public function initialize(\Sabre\DAV\Server $server): void {
$server->on('afterMethod:*', [$this, 'afterMethod']);
$server->on('beforeMethod:*', [$this, 'beforeMethod']);
}

/**
Expand All @@ -28,7 +28,7 @@ public function initialize(\Sabre\DAV\Server $server): void {
* @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());
}
Expand Down
4 changes: 3 additions & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,9 @@ public static function handleRequest(): void {
// 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
Expand Down
Loading