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
6d9efba1
Commit
6d9efba1
authored
Oct 24, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor applications service
parent
fd6e03de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
9 deletions
+7
-9
app/controllers/admin/applications_controller.rb
app/controllers/admin/applications_controller.rb
+1
-1
app/controllers/oauth/applications_controller.rb
app/controllers/oauth/applications_controller.rb
+1
-2
app/services/applications/create_service.rb
app/services/applications/create_service.rb
+1
-2
ee/app/services/ee/applications/create_service.rb
ee/app/services/ee/applications/create_service.rb
+4
-4
No files found.
app/controllers/admin/applications_controller.rb
View file @
6d9efba1
...
...
@@ -19,7 +19,7 @@ class Admin::ApplicationsController < Admin::ApplicationController
end
def
create
@application
=
Applications
::
CreateService
.
new
(
current_user
,
application_params
.
merge
(
ip_address:
request
.
remote_ip
)).
execute
@application
=
Applications
::
CreateService
.
new
(
current_user
,
application_params
).
execute
(
request
)
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
...
...
app/controllers/oauth/applications_controller.rb
View file @
6d9efba1
...
...
@@ -16,7 +16,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
end
def
create
@application
=
Applications
::
CreateService
.
new
(
current_user
,
create_application_params
).
execute
@application
=
Applications
::
CreateService
.
new
(
current_user
,
create_application_params
).
execute
(
request
)
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
...
...
@@ -58,7 +58,6 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
def
create_application_params
application_params
.
tap
do
|
params
|
params
[
:owner
]
=
current_user
params
[
:ip_address
]
=
request
.
remote_ip
end
end
end
app/services/applications/create_service.rb
View file @
6d9efba1
...
...
@@ -5,10 +5,9 @@ module Applications
def
initialize
(
current_user
,
params
)
@current_user
=
current_user
@params
=
params
@ip_address
=
@params
.
delete
(
:ip_address
)
end
def
execute
def
execute
(
request
=
nil
)
Doorkeeper
::
Application
.
create
(
@params
)
end
end
...
...
ee/app/services/ee/applications/create_service.rb
View file @
6d9efba1
module
EE
module
Applications
module
CreateService
def
execute
def
execute
(
request
)
super
.
tap
do
|
application
|
audit_event_service
.
for_user
(
application
.
name
).
security_event
audit_event_service
(
request
.
ip_address
)
.
for_user
(
application
.
name
).
security_event
end
end
def
audit_event_service
def
audit_event_service
(
ip_address
)
::
AuditEventService
.
new
(
@current_user
,
@current_user
,
action: :custom
,
custom_message:
'OAuth access granted'
,
ip_address:
@
ip_address
)
ip_address:
ip_address
)
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