Skip to content
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

fix: disallow updating files for links and links for files #2084

Merged
merged 1 commit into from
Nov 24, 2022

Conversation

halfwhole
Copy link
Collaborator

@halfwhole halfwhole commented Nov 16, 2022

Problem

One can manually submit a request (PATCH /api/user/url) to update the longUrl for a file, or the file for a link. This should not be allowed.

Screenshot 2022-11-16 at 11 25 32 AM

Solution

Disallow updating files for links and links for files at the service layer, depending on the isFile field of the URL.

  • Return a 400 bad request on the user and API controller when encountering this error
  • Created a new error type InvalidUrlUpdateError for this, because it didn't seem to fall under any existing error type - not sure of my approach though, happy to modify where necessary

@halfwhole halfwhole requested a review from thanhdatle November 17, 2022 08:41
Copy link
Contributor

@thanhdatle thanhdatle left a comment

Choose a reason for hiding this comment

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

LGTM

@halfwhole halfwhole merged commit 5710558 into develop Nov 24, 2022
@halfwhole halfwhole deleted the fix/invalid-url-update-file-link branch November 24, 2022 08:04
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.

2 participants