Check actual file if it can be updated

There is no need to check the root folder because it doesn't tell you if
the file itself is updatable.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2019-03-21 21:10:19 +01:00
Родитель 18a7939ab2
Коммит 7d8846a96f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F941078878347C0C
1 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -99,7 +99,16 @@ class TokenManager {
try {
$editoruid = $this->userId;
$rootFolder = $this->rootFolder->getUserFolder($editoruid);
$updatable = $rootFolder->isUpdateable();
$files = $rootFolder->getById((int)$fileId);
$updatable = false;
foreach ($files as $file) {
if ($file->isUpdateable()) {
$updatable = true;
break;
}
}
// Check if the editor (user who is accessing) is in editable group
// UserCanWrite only if
// 1. No edit groups are set or
@ -163,8 +172,7 @@ class TokenManager {
public function getTokenForTemplate(File $file, $userId, $templateDestination) {
$owneruid = $userId;
$editoruid = $userId;
$rootFolder = $this->rootFolder->getUserFolder($editoruid);
$updatable = $rootFolder->isUpdateable();
$updatable = $file->isUpdateable();
// Check if the editor (user who is accessing) is in editable group
// UserCanWrite only if
// 1. No edit groups are set or