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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
6db2843b
Commit
6db2843b
authored
Sep 10, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix of project creation
parent
f5af4efa
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
7 additions
and
151 deletions
+7
-151
app/controllers/ci/projects_controller.rb
app/controllers/ci/projects_controller.rb
+1
-1
app/controllers/ci/user_sessions_controller.rb
app/controllers/ci/user_sessions_controller.rb
+0
-55
app/models/ci/network.rb
app/models/ci/network.rb
+1
-1
app/models/ci/user.rb
app/models/ci/user.rb
+0
-67
app/models/ci/user_session.rb
app/models/ci/user_session.rb
+0
-23
app/services/ci/create_project_service.rb
app/services/ci/create_project_service.rb
+1
-1
app/services/ci/register_build_service.rb
app/services/ci/register_build_service.rb
+1
-1
app/views/ci/admin/projects/index.html.haml
app/views/ci/admin/projects/index.html.haml
+2
-1
app/views/ci/projects/_gl_projects.html.haml
app/views/ci/projects/_gl_projects.html.haml
+1
-1
No files found.
app/controllers/ci/projects_controller.rb
View file @
6db2843b
...
...
@@ -55,7 +55,7 @@ module Ci
def
create
project_data
=
OpenStruct
.
new
(
JSON
.
parse
(
params
[
"project"
]))
unless
can?
(
current_user
,
:
manage
_project
,
::
Project
.
find
(
project_data
.
id
))
unless
can?
(
current_user
,
:
admin
_project
,
::
Project
.
find
(
project_data
.
id
))
return
redirect_to
ci_root_path
,
alert:
'You have to have at least master role to enable CI for this project'
end
...
...
app/controllers/ci/user_sessions_controller.rb
deleted
100644 → 0
View file @
f5af4efa
module
Ci
class
UserSessionsController
<
Ci
::
ApplicationController
before_filter
:authenticate_user!
,
except:
[
:new
,
:callback
,
:auth
]
def
show
@user
=
current_user
end
def
new
end
def
auth
redirect_to
client
.
auth_code
.
authorize_url
({
redirect_uri:
callback_ci_user_sessions_url
,
state:
params
[
:state
]
})
end
def
callback
token
=
client
.
auth_code
.
get_token
(
params
[
:code
],
redirect_uri:
callback_ci_user_sessions_url
).
token
@user_session
=
Ci
::
UserSession
.
new
user
=
@user_session
.
authenticate
(
access_token:
token
)
if
user
&&
sign_in
(
user
)
return_to
=
get_ouath_state_return_to
(
params
[
:state
])
redirect_to
(
return_to
||
ci_root_path
)
else
@error
=
'Invalid credentials'
render
:new
end
end
def
destroy
sign_out
redirect_to
new_ci_user_sessions_path
end
protected
def
client
@client
||=
::
OAuth2
::
Client
.
new
(
GitlabCi
.
config
.
gitlab_server
.
app_id
,
GitlabCi
.
config
.
gitlab_server
.
app_secret
,
{
site:
GitlabCi
.
config
.
gitlab_server
.
url
,
authorize_url:
'oauth/authorize'
,
token_url:
'oauth/token'
}
)
end
end
end
app/models/ci/network.rb
View file @
6db2843b
...
...
@@ -99,7 +99,7 @@ module Ci
private
def
url
Gitlab
Ci
.
config
.
gitlab_server
.
url
Gitlab
.
config
.
gitlab
.
url
end
def
default_opts
...
...
app/models/ci/user.rb
deleted
100644 → 0
View file @
f5af4efa
# User object is stored in session
module
Ci
class
User
DEVELOPER_ACCESS
=
30
attr_reader
:attributes
def
initialize
(
hash
)
@attributes
=
hash
end
def
gitlab_projects
(
search
=
nil
,
page
=
1
,
per_page
=
100
)
Rails
.
cache
.
fetch
(
cache_key
(
page
,
per_page
,
search
))
do
Ci
::
Project
.
from_gitlab
(
self
,
:authorized
,
{
page:
page
,
per_page:
per_page
,
search:
search
,
ci_enabled_first:
true
})
end
end
def
method_missing
(
meth
,
*
args
,
&
block
)
if
attributes
.
has_key?
(
meth
.
to_s
)
attributes
[
meth
.
to_s
]
else
super
end
end
def
avatar_url
attributes
[
'avatar_url'
]
end
def
cache_key
(
*
args
)
"
#{
self
.
id
}
:
#{
args
.
join
(
":"
)
}
:
#{
sync_at
.
to_s
}
"
end
def
sync_at
@sync_at
||=
Time
.
now
end
def
reset_cache
@sync_at
=
Time
.
now
end
def
authorized_runners
Ci
::
Runner
.
specific
.
includes
(
:runner_projects
).
where
(
Ci
::
RunnerProject
.
table_name
=>
{
project_id:
authorized_projects
}
)
end
def
authorized_projects
Ci
::
Project
.
where
(
gitlab_id:
current_user
.
authorized_projects
.
map
(
&
:id
))
end
def
authenticate_options
if
attributes
[
'access_token'
]
{
access_token:
attributes
[
'access_token'
]
}
else
{
private_token:
attributes
[
'private_token'
]
}
end
end
private
def
project_info
(
project_gitlab_id
)
Rails
.
cache
.
fetch
(
cache_key
(
"project_info"
,
project_gitlab_id
,
sync_at
))
do
Ci
::
Network
.
new
.
project
(
authenticate_options
,
project_gitlab_id
)
end
end
end
end
app/models/ci/user_session.rb
deleted
100644 → 0
View file @
f5af4efa
module
Ci
class
UserSession
include
ActiveModel
::
Conversion
include
Ci
::
StaticModel
extend
ActiveModel
::
Naming
def
authenticate
(
auth_opts
)
network
=
Ci
::
Network
.
new
user
=
network
.
authenticate
(
auth_opts
)
if
user
user
[
"access_token"
]
=
auth_opts
[
:access_token
]
return
Ci
::
User
.
new
(
user
)
else
nil
end
user
rescue
nil
end
end
end
app/services/ci/create_project_service.rb
View file @
6db2843b
...
...
@@ -13,7 +13,7 @@ module Ci
project_url:
project_route
.
gsub
(
":project_id"
,
@project
.
id
.
to_s
),
}
unless
Ci
::
Network
.
new
.
enable_ci
(
@project
.
gitlab_id
,
data
,
current_user
.
authenticate_options
)
unless
Ci
::
Network
.
new
.
enable_ci
(
@project
.
gitlab_id
,
data
,
{
private_token:
current_user
.
private_token
}
)
raise
ActiveRecord
::
Rollback
end
end
...
...
app/services/ci/register_build_service.rb
View file @
6db2843b
...
...
@@ -8,7 +8,7 @@ module Ci
builds
=
if
current_runner
.
shared?
# don't run projects which have not enables shared runners
builds
.
includes
(
:project
).
where
(
projects:
{
shared_runners_enabled:
true
})
builds
.
includes
(
:project
).
where
(
ci_
projects:
{
shared_runners_enabled:
true
})
else
# do run projects which are only assigned to this runner
builds
.
where
(
project_id:
current_runner
.
projects
)
...
...
app/views/ci/admin/projects/index.html.haml
View file @
6db2843b
...
...
@@ -8,7 +8,8 @@
%th
Builds
%th
=
render
@projects
-
@projects
.
each
do
|
project
|
=
render
"ci/admin/projects/project"
,
project:
@projects
=
paginate
@projects
app/views/ci/projects/_gl_projects.html.haml
View file @
6db2843b
...
...
@@ -11,5 +11,5 @@
Added
-
else
=
form_tag
ci_projects_path
do
=
hidden_field_tag
:project
,
project
.
to_json
=
hidden_field_tag
:project
,
project
.
to_json
(
methods:
[
:name_with_namespace
,
:path_with_namespace
,
:ssh_url_to_repo
])
=
submit_tag
'Add project to CI'
,
class:
'btn btn-default btn-sm'
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