pundit: convert dmails to pundit.

This commit is contained in:
evazion
2020-03-18 01:01:40 -05:00
parent 19817a6f85
commit 480f39c34a
5 changed files with 49 additions and 54 deletions

View File

@@ -0,0 +1,29 @@
class DmailPolicy < ApplicationPolicy
def create?
unbanned?
end
def index?
user.is_member?
end
def mark_all_as_read?
user.is_member?
end
def update?
user.is_member? && record.owner_id == user.id
end
def show?
user.is_member? && (record.owner_id == user.id || record.valid_key?(request.params[:key]))
end
def permitted_attributes_for_create
[:title, :body, :to_name, :to_id]
end
def permitted_attributes_for_update
[:is_read, :is_deleted]
end
end