Welcome to mirror list, hosted at ThFree Co, Russian Federation.

todo_policy.rb « policies « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6237fbc50fa910a3b0c0b5b77271fd2cd445753f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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
  condition(:can_read_target) do
    @user && @subject.target&.readable_by?(@user)
  end

  rule { own_todo & can_read_target }.enable :read_todo
  rule { own_todo & can_read_target }.enable :update_todo
end