Skip to content

Fix: Prevent re-requesting approval for already approved files#399

Open
Amitdwivedi22 wants to merge 1 commit intonextcloud:mainfrom
Amitdwivedi22:fix/prevent-duplicate-approval
Open

Fix: Prevent re-requesting approval for already approved files#399
Amitdwivedi22 wants to merge 1 commit intonextcloud:mainfrom
Amitdwivedi22:fix/prevent-duplicate-approval

Conversation

@Amitdwivedi22
Copy link
Copy Markdown

@Amitdwivedi22 Amitdwivedi22 commented Mar 17, 2026

Fix: Prevent re-requesting approval for already approved files

  • Added backend validation in ApprovalService to block approval requests if file is already approved
  • Improved frontend logic to hide request button after approval

Closes #398

Copy link
Copy Markdown
Member

@lukasdotcom lukasdotcom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Amitdwivedi22,

Thanks for the contribution. Could you sign your commits? There are instructions at https://github.com/nextcloud/approval/pull/399/checks?check_run_id=67481178296

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);
Copy link
Copy Markdown
Member

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.


$state = $this->getApprovalState($fileId, $userId);

if ($state['state'] === \OCA\Approval\AppInfo\Application::STATE_APPROVED) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($state['state'] === \OCA\Approval\AppInfo\Application::STATE_APPROVED) {
if ($state['state'] === Application::STATE_APPROVED) {

},
canRequestApproval() {
return this.userRules.length > 0
return this.userRules.length > 0 && this.state !== states.APPROVED
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

@lukasdotcom
Copy link
Copy Markdown
Member

For fixing the php-cs workflow you can run composer cs:fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API allows rerequesting approval of approved files

2 participants