aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/DirectEditing/Manager.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php
index e6efc6d28aa..039944e2491 100644
--- a/lib/private/DirectEditing/Manager.php
+++ b/lib/private/DirectEditing/Manager.php
@@ -59,6 +59,8 @@ class Manager implements IManager {
private $editors = [];
/** @var IDBConnection */
private $connection;
+ /** @var IUserSession */
+ private $userSession;
/** @var ISecureRandom */
private $random;
/** @var string|null */
@@ -80,6 +82,7 @@ class Manager implements IManager {
) {
$this->random = $random;
$this->connection = $connection;
+ $this->userSession = $userSession;
$this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
$this->rootFolder = $rootFolder;
$this->l10n = $l10nFactory->get('lib');
@@ -185,7 +188,13 @@ class Manager implements IManager {
$this->invalidateToken($token);
return new NotFoundResponse();
}
- return $editor->open($tokenObject);
+
+ try {
+ $this->invokeTokenScope($tokenObject->getUser());
+ return $editor->open($tokenObject);
+ } finally {
+ $this->revertTokenScope();
+ }
}
public function editSecure(File $file, string $editorId): TemplateResponse {
@@ -250,6 +259,11 @@ class Manager implements IManager {
\OC_User::setUserId($userId);
}
+ public function revertTokenScope(): void {
+ $this->userSession->setUser(null);
+ \OC_User::setIncognitoMode(false);
+ }
+
public function createToken($editorId, File $file, string $filePath, IShare $share = null): string {
$token = $this->random->generate(64, ISecureRandom::CHAR_HUMAN_READABLE);
$query = $this->connection->getQueryBuilder();