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
a340829c
Commit
a340829c
authored
Aug 18, 2016
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
port UserPolicy
parent
5019185e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
app/models/ability.rb
app/models/ability.rb
+0
-11
app/policies/user_policy.rb
app/policies/user_policy.rb
+11
-0
No files found.
app/models/ability.rb
View file @
a340829c
...
@@ -73,7 +73,6 @@ class Ability
...
@@ -73,7 +73,6 @@ class Ability
def
abilities_by_subject_class
(
user
:,
subject
:)
def
abilities_by_subject_class
(
user
:,
subject
:)
case
subject
case
subject
when
User
then
user_abilities
when
ExternalIssue
,
Deployment
,
Environment
then
project_abilities
(
user
,
subject
.
project
)
when
ExternalIssue
,
Deployment
,
Environment
then
project_abilities
(
user
,
subject
.
project
)
else
[]
else
[]
end
+
global_abilities
(
user
)
end
+
global_abilities
(
user
)
...
@@ -85,17 +84,11 @@ class Ability
...
@@ -85,17 +84,11 @@ class Ability
ProjectPolicy
.
abilities
(
nil
,
subject
.
project
)
ProjectPolicy
.
abilities
(
nil
,
subject
.
project
)
elsif
subject
.
respond_to?
(
:group
)
elsif
subject
.
respond_to?
(
:group
)
GroupPolicy
.
abilities
(
nil
,
subject
.
group
)
GroupPolicy
.
abilities
(
nil
,
subject
.
group
)
elsif
subject
.
is_a?
(
User
)
anonymous_user_abilities
else
else
[]
[]
end
end
end
end
def
anonymous_user_abilities
[
:read_user
]
unless
restricted_public_level?
end
def
global_abilities
(
user
)
def
global_abilities
(
user
)
rules
=
[]
rules
=
[]
rules
<<
:create_group
if
user
.
can_create_group
rules
<<
:create_group
if
user
.
can_create_group
...
@@ -136,10 +129,6 @@ class Ability
...
@@ -136,10 +129,6 @@ class Ability
rules
rules
end
end
def
user_abilities
[
:read_user
]
end
def
restricted_public_level?
def
restricted_public_level?
current_application_settings
.
restricted_visibility_levels
.
include?
(
Gitlab
::
VisibilityLevel
::
PUBLIC
)
current_application_settings
.
restricted_visibility_levels
.
include?
(
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
end
...
...
app/policies/user_policy.rb
0 → 100644
View file @
a340829c
class
UserPolicy
<
BasePolicy
include
Gitlab
::
CurrentSettings
def
rules
can!
:read_user
if
@user
||
!
restricted_public_level?
end
def
restricted_public_level?
current_application_settings
.
restricted_visibility_levels
.
include?
(
Gitlab
::
VisibilityLevel
::
PUBLIC
)
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