Skip to content
Snippets Groups Projects
Unverified Commit 68b764bb authored by Christoph Wurst's avatar Christoph Wurst
Browse files

Do not allow transfer ownership when the user isn't the owner

parent 26ea9681
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -96,6 +96,10 @@ class TransferOwnershipController extends OCSController { ...@@ -96,6 +96,10 @@ class TransferOwnershipController extends OCSController {
return new DataResponse([], Http::STATUS_BAD_REQUEST); return new DataResponse([], Http::STATUS_BAD_REQUEST);
} }
if ($node->getOwner()->getUID() !== $this->userId) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
$transferOwnership = new TransferOwnershipEntity(); $transferOwnership = new TransferOwnershipEntity();
$transferOwnership->setSourceUser($this->userId); $transferOwnership->setSourceUser($this->userId);
$transferOwnership->setTargetUser($recipient); $transferOwnership->setTargetUser($recipient);
......
...@@ -215,7 +215,11 @@ export default { ...@@ -215,7 +215,11 @@ export default {
.catch(error => { .catch(error => {
logger.error('Could not send ownership transfer request', { error }) logger.error('Could not send ownership transfer request', { error })
this.submitError = error.message || t('files', 'Unknown error') if (error?.response?.status === 403) {
this.submitError = t('files', 'Cannot transfter ownership of a file or folder you don\'t own')
} else {
this.submitError = error.message || t('files', 'Unknown error')
}
}) })
}, },
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment