Skip to content

Commit b2a17b4

Browse files
icewind1991backportbot[bot]
authored andcommitted
feat: add header with user id in response
Signed-off-by: Robin Appelman <robin@icewind.nl> [skip ci]
1 parent 1728d02 commit b2a17b4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/public/AppFramework/Http/Response.php

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

1618
/**
@@ -246,6 +248,11 @@ public function getHeaders() {
246248
$mergeWith['ETag'] = '"' . $this->ETag . '"';
247249
}
248250

251+
$userSession = Server::get(IUserSession::class);
252+
if ($user = $userSession->getUser()) {
253+
$mergeWith['X-User-Id'] = $user->getUID();
254+
}
255+
249256
return array_merge($mergeWith, $this->headers);
250257
}
251258

0 commit comments

Comments
 (0)