Skip to content

Commit eb03573

Browse files
committed
feat: add header with user id in response
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 467c079 commit eb03573

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/public/AppFramework/Http/Response.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OCP\AppFramework\Utility\ITimeFactory;
1212
use OCP\IConfig;
1313
use OCP\IRequest;
14+
use OCP\IUserSession;
1415
use Psr\Log\LoggerInterface;
1516

1617
/**
@@ -246,6 +247,11 @@ public function getHeaders() {
246247
$mergeWith['ETag'] = '"' . $this->ETag . '"';
247248
}
248249

250+
$userSession = \OC::$server->get(IUserSession::class);
251+
if ($user = $userSession->getUser()) {
252+
$mergeWith['X-User-Id'] = $user->getUID();
253+
}
254+
249255
return array_merge($mergeWith, $this->headers);
250256
}
251257

0 commit comments

Comments
 (0)