BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a9765fb4
Commit
a9765fb4
authored
Nov 16, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce has_access_to? so that we could reuse it
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7383#note_18439108
parent
72147812
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
6 deletions
+13
-6
projects_helper.rb
app/helpers/projects_helper.rb
+2
-2
deploy_key.rb
app/models/deploy_key.rb
+5
-1
user.rb
app/models/user.rb
+4
-0
result.rb
lib/gitlab/auth/result.rb
+1
-2
git_access.rb
lib/gitlab/git_access.rb
+1
-1
No files found.
app/helpers/projects_helper.rb
View file @
a9765fb4
...
...
@@ -93,10 +93,10 @@ module ProjectsHelper
end
def
project_for_deploy_key
(
deploy_key
)
if
deploy_key
.
projects
.
include
?
(
@project
)
if
deploy_key
.
has_access_to
?
(
@project
)
@project
else
deploy_key
.
projects
.
find
{
|
project
|
can?
(
current_user
,
:read_project
,
project
)
}
deploy_key
.
projects
.
find
(
&
current_user
.
method
(
:has_access_to?
))
end
end
...
...
app/models/deploy_key.rb
View file @
a9765fb4
...
...
@@ -21,7 +21,11 @@ class DeployKey < Key
self
.
private?
end
def
has_access_to?
(
project
)
projects
.
include?
(
project
)
end
def
can_push_to?
(
project
)
can_push?
&&
projects
.
include
?
(
project
)
can_push?
&&
has_access_to
?
(
project
)
end
end
app/models/user.rb
View file @
a9765fb4
...
...
@@ -501,6 +501,10 @@ class User < ActiveRecord::Base
several_namespaces?
||
admin
end
def
has_access_to?
(
project
)
can?
(
:read_project
,
project
)
end
def
can?
(
action
,
subject
)
Ability
.
allowed?
(
self
,
action
,
subject
)
end
...
...
lib/gitlab/auth/result.rb
View file @
a9765fb4
...
...
@@ -9,8 +9,7 @@ module Gitlab
def
lfs_deploy_token?
(
for_project
)
type
==
:lfs_deploy_token
&&
actor
&&
actor
.
projects
.
include?
(
for_project
)
actor
.
try
(
:has_access_to?
,
for_project
)
end
def
success?
...
...
lib/gitlab/git_access.rb
View file @
a9765fb4
...
...
@@ -161,7 +161,7 @@ module Gitlab
def
can_read_project?
if
deploy_key
project
.
public?
||
deploy_key
.
projects
.
include
?
(
project
)
project
.
public?
||
deploy_key
.
has_access_to
?
(
project
)
elsif
user
user_access
.
can_read_project?
else
...
...
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