feat(policies): add CommentPolicy, update? and LikePolicy
This commit is contained in:
1 parent
5025bb8d9c
commit
4160704b23
3 files changed
+43
No files matched your search
@@ -0,0 +1,25 @@
|
||||
class CommentPolicy < Prism::Policy
|
||||
def update?
|
||||
user && record.user_id == user.id
|
||||
end
|
||||
|
||||
def destroy?
|
||||
update?
|
||||
end
|
||||
|
||||
def restore?
|
||||
update?
|
||||
end
|
||||
|
||||
# Approving/rejecting is a moderation call, not an authorship one - it
|
||||
# belongs to whoever owns the post the comment hangs off of, same as the
|
||||
# nested-attributes moderation form on PostsController#update (which goes
|
||||
# through PostPolicy#update? instead, since that request targets the post).
|
||||
def approve?
|
||||
user && record.post.user_id == user.id
|
||||
end
|
||||
|
||||
def reject?
|
||||
approve?
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user