mirror of
https://github.com/nextcloud/server.git
synced 2026-03-29 05:43:57 -04:00
Merge pull request #55502 from nextcloud/backport/55176/stable32
[stable32] feat: add header with user id in response
This commit is contained in:
commit
db4102b747
1 changed files with 8 additions and 1 deletions
|
|
@ -11,6 +11,8 @@ use OCP\AppFramework\Http;
|
|||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -228,7 +230,7 @@ class Response {
|
|||
/**
|
||||
* @psalm-suppress UndefinedClass
|
||||
*/
|
||||
$request = \OCP\Server::get(IRequest::class);
|
||||
$request = Server::get(IRequest::class);
|
||||
$mergeWith = [
|
||||
'X-Request-Id' => $request->getId(),
|
||||
'Cache-Control' => 'no-cache, no-store, must-revalidate',
|
||||
|
|
@ -245,6 +247,11 @@ class Response {
|
|||
$mergeWith['ETag'] = '"' . $this->ETag . '"';
|
||||
}
|
||||
|
||||
$userSession = Server::get(IUserSession::class);
|
||||
if ($user = $userSession->getUser()) {
|
||||
$mergeWith['X-User-Id'] = $user->getUID();
|
||||
}
|
||||
|
||||
return array_merge($mergeWith, $this->headers);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue