Skip to content

feature: field level file authorization#1625

Merged
adrianthedev merged 5 commits into
mainfrom
feature/field_level_file_authorization
Mar 12, 2023
Merged

feature: field level file authorization#1625
adrianthedev merged 5 commits into
mainfrom
feature/field_level_file_authorization

Conversation

@Paul-Bob

@Paul-Bob Paul-Bob commented Mar 12, 2023

Copy link
Copy Markdown
Contributor

Description

Now we can police each file using field level authorization methods.

# app/avo/resources/post_resource.rb
field :cover_photo, as: :file, is_image: true
# app/policies/post_policy.rb
def upload_cover_photo?
  user.student?
end

def download_cover_photo?
  true
end

def delete_cover_photo?
  user.admin?
end

Fixes #1624

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Docs PR avo-hq/docs.avohq.io#25

@Paul-Bob Paul-Bob requested a review from adrianthedev March 12, 2023 13:24
@Paul-Bob Paul-Bob self-assigned this Mar 12, 2023
@qlty-cloud-legacy

qlty-cloud-legacy Bot commented Mar 12, 2023

Copy link
Copy Markdown

Code Climate has analyzed commit 0e3338e and detected 0 issues on this pull request.

View more on Code Climate.

@adrianthedev adrianthedev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The PR looks perfect!
I left a tiny suggestion to make the code easier to understand in the long run.

Thank you!

Comment thread lib/avo/fields/concerns/file_authorization.rb Outdated
@adrianthedev adrianthedev merged commit 667049c into main Mar 12, 2023
@adrianthedev adrianthedev deleted the feature/field_level_file_authorization branch March 12, 2023 17:43
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

@Paul-Bob Paul-Bob mentioned this pull request Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Field level file authorization

2 participants