-
Notifications
You must be signed in to change notification settings - Fork 10
Fix: Prevent re-requesting approval for already approved files #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -446,7 +446,16 @@ public function reject(int $fileId, ?string $userId, string $message = '', strin | |||||
| * @throws \OCP\Files\NotPermittedException | ||||||
| * @throws \OC\User\NoUserException | ||||||
| */ | ||||||
| public function request(int $fileId, int $ruleId, ?string $userId, bool $createShares): array { | ||||||
| public function request(int $fileId, int $ruleId, ?string $userId, bool $createShares) { | ||||||
|
|
||||||
| $state = $this->getApprovalState($fileId, $userId); | ||||||
|
|
||||||
| if ($state['state'] === \OCA\Approval\AppInfo\Application::STATE_APPROVED) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return [ | ||||||
| 'error' => 'File already approved. Cannot request approval again.' | ||||||
| ]; | ||||||
| } | ||||||
|
|
||||||
| if (!$this->utilsService->userHasAccessTo($fileId, $userId)) { | ||||||
| return ['error' => $this->l10n->t('You do not have access to this file')]; | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,7 +188,7 @@ export default { | |
| return this.userId !== getCurrentUser().uid | ||
| }, | ||
| canRequestApproval() { | ||
| return this.userRules.length > 0 | ||
| return this.userRules.length > 0 && this.state !== states.APPROVED | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't necessary as it only matters that you can't re-request approval for the same workflow. Some users may have two approval flows they want on the same file. |
||
| }, | ||
| ruleText() { | ||
| if ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is done before ensuring that the user has access to the file which could leak information.