debian-mirror-gitlab/app/policies/todo_policy.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
381 B
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
class TodoPolicy < BasePolicy
desc 'User can only read own todos'
condition(:own_todo) do
@user && @subject.user_id == @user.id
end
2021-08-04 16:29:09 +05:30
condition(:can_read_target) do
@user && @subject.target&.readable_by?(@user)
end
2019-12-21 20:55:43 +05:30
2021-08-04 16:29:09 +05:30
rule { own_todo & can_read_target }.enable :read_todo
rule { own_todo & can_read_target }.enable :update_todo
2019-12-21 20:55:43 +05:30
end