add personal snippets and project members
This commit is contained in:
parent
9a0ea13501
commit
29059c2e9c
2 changed files with 38 additions and 0 deletions
16
app/policies/personal_snippet_policy.rb
Normal file
16
app/policies/personal_snippet_policy.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
class PersonalSnippetPolicy < BasePolicy
|
||||||
|
def rules
|
||||||
|
can! :read_personal_snippet if @subject.public?
|
||||||
|
return unless @user
|
||||||
|
|
||||||
|
if @subject.author == @user
|
||||||
|
can! :read_personal_snippet
|
||||||
|
can! :update_personal_snippet
|
||||||
|
can! :admin_personal_snippet
|
||||||
|
end
|
||||||
|
|
||||||
|
if @subject.internal? && !@user.external?
|
||||||
|
can! :read_personal_snippet
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
22
app/policies/project_member_policy.rb
Normal file
22
app/policies/project_member_policy.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue