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
Léo-Paul Géneau
gitlab-ce
Commits
756d6156
Commit
756d6156
authored
Nov 17, 2015
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
...
@@ -2,7 +2,7 @@ class Ability
class
<<
self
class
<<
self
def
allowed
(
user
,
subject
)
def
allowed
(
user
,
subject
)
return
not_auth_abilities
(
user
,
subject
)
if
user
.
nil?
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?
return
[]
if
user
.
blocked?
case
subject
.
class
.
name
case
subject
.
class
.
name
...
@@ -22,14 +22,20 @@ class Ability
...
@@ -22,14 +22,20 @@ class Ability
# List of possible abilities
# List of possible abilities
# for non-authenticated user
# for non-authenticated user
def
not_auth_abilities
(
user
,
subject
)
def
not_auth_abilities
(
user
,
subject
)
return
not_auth_personal_snippet_abilities
(
subject
)
if
subject
.
kind_of?
(
PersonalSnippet
)
case
true
return
not_auth_project_abilities
(
subject
)
if
subject
.
kind_of?
(
Project
)
||
subject
.
respond_to?
(
:project
)
when
subject
.
is_a?
(
PersonalSnippet
)
return
not_auth_group_abilities
(
subject
)
if
subject
.
kind_of?
(
Group
)
||
subject
.
respond_to?
(
:group
)
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
end
def
not_auth_project_abilities
(
subject
)
def
not_auth_project_abilities
(
subject
)
project
=
if
subject
.
kind_of
?
(
Project
)
project
=
if
subject
.
is_a
?
(
Project
)
subject
subject
else
else
subject
.
project
subject
.
project
...
@@ -57,7 +63,7 @@ class Ability
...
@@ -57,7 +63,7 @@ class Ability
end
end
def
not_auth_group_abilities
(
subject
)
def
not_auth_group_abilities
(
subject
)
group
=
if
subject
.
kind_of
?
(
Group
)
group
=
if
subject
.
is_a
?
(
Group
)
subject
subject
else
else
subject
.
group
subject
.
group
...
@@ -327,7 +333,7 @@ class Ability
...
@@ -327,7 +333,7 @@ class Ability
end
end
if
snippet
.
public?
||
snippet
.
internal?
if
snippet
.
public?
||
snippet
.
internal?
rules
.
push
(
:read_personal_snippet
)
rules
<<
:read_personal_snippet
end
end
rules
rules
...
...
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