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
def
abilities_by_subject_class
(
user
:,
subject
:)
case
subject
when
User
then
user_abilities
when
ExternalIssue
,
Deployment
,
Environment
then
project_abilities
(
user
,
subject
.
project
)
else
[]
end
+
global_abilities
(
user
)
...
...
@@ -85,17 +84,11 @@ class Ability
ProjectPolicy
.
abilities
(
nil
,
subject
.
project
)
elsif
subject
.
respond_to?
(
:group
)
GroupPolicy
.
abilities
(
nil
,
subject
.
group
)
elsif
subject
.
is_a?
(
User
)
anonymous_user_abilities
else
[]
end
end
def
anonymous_user_abilities
[
:read_user
]
unless
restricted_public_level?
end
def
global_abilities
(
user
)
rules
=
[]
rules
<<
:create_group
if
user
.
can_create_group
...
...
@@ -136,10 +129,6 @@ class Ability
rules
end
def
user_abilities
[
:read_user
]
end
def
restricted_public_level?
current_application_settings
.
restricted_visibility_levels
.
include?
(
Gitlab
::
VisibilityLevel
::
PUBLIC
)
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