Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
29059c2e
Commit
29059c2e
authored
Aug 16, 2016
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add personal snippets and project members
parent
9a0ea135
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
app/policies/personal_snippet_policy.rb
app/policies/personal_snippet_policy.rb
+16
-0
app/policies/project_member_policy.rb
app/policies/project_member_policy.rb
+22
-0
No files found.
app/policies/personal_snippet_policy.rb
0 → 100644
View file @
29059c2e
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
app/policies/project_member_policy.rb
0 → 100644
View file @
29059c2e
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment