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
90d924dc
Commit
90d924dc
authored
Mar 09, 2017
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverse the logic and use a clearer name
parent
66f204e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
lib/gitlab/user_access.rb
lib/gitlab/user_access.rb
+7
-7
No files found.
lib/gitlab/user_access.rb
View file @
90d924dc
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
end
end
def
can_do_action?
(
action
)
def
can_do_action?
(
action
)
return
false
if
no_user_or_blocked
?
return
false
unless
can_access_git
?
@permission_cache
||=
{}
@permission_cache
||=
{}
@permission_cache
[
action
]
||=
user
.
can?
(
action
,
project
)
@permission_cache
[
action
]
||=
user
.
can?
(
action
,
project
)
...
@@ -19,7 +19,7 @@ module Gitlab
...
@@ -19,7 +19,7 @@ module Gitlab
end
end
def
allowed?
def
allowed?
return
false
if
no_user_or_blocked
?
return
false
unless
can_access_git
?
if
user
.
requires_ldap_check?
&&
user
.
try_obtain_ldap_lease
if
user
.
requires_ldap_check?
&&
user
.
try_obtain_ldap_lease
return
false
unless
Gitlab
::
LDAP
::
Access
.
allowed?
(
user
)
return
false
unless
Gitlab
::
LDAP
::
Access
.
allowed?
(
user
)
...
@@ -29,7 +29,7 @@ module Gitlab
...
@@ -29,7 +29,7 @@ module Gitlab
end
end
def
can_push_to_branch?
(
ref
)
def
can_push_to_branch?
(
ref
)
return
false
if
no_user_or_blocked
?
return
false
unless
can_access_git
?
if
project
.
protected_branch?
(
ref
)
if
project
.
protected_branch?
(
ref
)
return
true
if
project
.
empty_repo?
&&
project
.
user_can_push_to_empty_repo?
(
user
)
return
true
if
project
.
empty_repo?
&&
project
.
user_can_push_to_empty_repo?
(
user
)
...
@@ -44,7 +44,7 @@ module Gitlab
...
@@ -44,7 +44,7 @@ module Gitlab
end
end
def
can_merge_to_branch?
(
ref
)
def
can_merge_to_branch?
(
ref
)
return
false
if
no_user_or_blocked
?
return
false
unless
can_access_git
?
if
project
.
protected_branch?
(
ref
)
if
project
.
protected_branch?
(
ref
)
access_levels
=
project
.
protected_branches
.
matching
(
ref
).
map
(
&
:merge_access_levels
).
flatten
access_levels
=
project
.
protected_branches
.
matching
(
ref
).
map
(
&
:merge_access_levels
).
flatten
...
@@ -55,15 +55,15 @@ module Gitlab
...
@@ -55,15 +55,15 @@ module Gitlab
end
end
def
can_read_project?
def
can_read_project?
return
false
if
no_user_or_blocked
?
return
false
unless
can_access_git
?
user
.
can?
(
:read_project
,
project
)
user
.
can?
(
:read_project
,
project
)
end
end
private
private
def
no_user_or_blocked
?
def
can_access_git
?
user
.
nil?
||
!
user
.
can?
(
:access_git
)
user
&&
user
.
can?
(
:access_git
)
end
end
end
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