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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/policies')
-rw-r--r--app/policies/todo_policy.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/policies/todo_policy.rb b/app/policies/todo_policy.rb
new file mode 100644
index 00000000000..f8644217f04
--- /dev/null
+++ b/app/policies/todo_policy.rb
@@ -0,0 +1,10 @@
+# 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
+
+ rule { own_todo }.enable :read_todo
+end