diff options
author | http://jneen.net/ <jneen@jneen.net> | 2016-08-17 02:46:35 +0300 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2016-08-30 21:39:22 +0300 |
commit | 29059c2e9c7be418d2a99a136934c6d9cca5fccd (patch) | |
tree | 4c54f77bd0df3078c6820e045298493c360b3221 /app/policies/project_member_policy.rb | |
parent | 9a0ea1350131368b9b723f1a9581bbfffe7c43f8 (diff) |
add personal snippets and project members
Diffstat (limited to 'app/policies/project_member_policy.rb')
-rw-r--r-- | app/policies/project_member_policy.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/policies/project_member_policy.rb b/app/policies/project_member_policy.rb new file mode 100644 index 00000000000..1c038dddd4b --- /dev/null +++ b/app/policies/project_member_policy.rb @@ -0,0 +1,22 @@ +class ProjectMemberPolicy < BasePolicy + def rules + # anonymous users have no abilities here + return unless @user + + target_user = @subject.user + project = @subject.project + + return if target_user == project.owner + + can_manage = Ability.allowed?(@user, :admin_project_member, project) + + if can_manage + can! :update_project_member + can! :destroy_project_member + end + + if @user == target_user + can! :destroy_project_member + end + end +end |