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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
756d6156
Commit
756d6156
authored
9 years ago
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring
parent
16438ad2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
app/models/ability.rb
app/models/ability.rb
+14
-8
No files found.
app/models/ability.rb
View file @
756d6156
...
...
@@ -2,7 +2,7 @@ class Ability
class
<<
self
def
allowed
(
user
,
subject
)
return
not_auth_abilities
(
user
,
subject
)
if
user
.
nil?
return
[]
unless
user
.
kind_of
?
(
User
)
return
[]
unless
user
.
is_a
?
(
User
)
return
[]
if
user
.
blocked?
case
subject
.
class
.
name
...
...
@@ -22,14 +22,20 @@ class Ability
# List of possible abilities
# for non-authenticated user
def
not_auth_abilities
(
user
,
subject
)
return
not_auth_personal_snippet_abilities
(
subject
)
if
subject
.
kind_of?
(
PersonalSnippet
)
return
not_auth_project_abilities
(
subject
)
if
subject
.
kind_of?
(
Project
)
||
subject
.
respond_to?
(
:project
)
return
not_auth_group_abilities
(
subject
)
if
subject
.
kind_of?
(
Group
)
||
subject
.
respond_to?
(
:group
)
case
true
when
subject
.
is_a?
(
PersonalSnippet
)
not_auth_personal_snippet_abilities
(
subject
)
when
subject
.
is_a?
(
Project
)
||
subject
.
respond_to?
(
:project
)
not_auth_project_abilities
(
subject
)
when
subject
.
is_a?
(
Group
)
||
subject
.
respond_to?
(
:group
)
not_auth_group_abilities
(
subject
)
else
[]
end
end
def
not_auth_project_abilities
(
subject
)
project
=
if
subject
.
kind_of
?
(
Project
)
project
=
if
subject
.
is_a
?
(
Project
)
subject
else
subject
.
project
...
...
@@ -57,7 +63,7 @@ class Ability
end
def
not_auth_group_abilities
(
subject
)
group
=
if
subject
.
kind_of
?
(
Group
)
group
=
if
subject
.
is_a
?
(
Group
)
subject
else
subject
.
group
...
...
@@ -327,7 +333,7 @@ class Ability
end
if
snippet
.
public?
||
snippet
.
internal?
rules
.
push
(
:read_personal_snippet
)
rules
<<
:read_personal_snippet
end
rules
...
...
This diff is collapsed.
Click to expand it.
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