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
60a1ffee
Commit
60a1ffee
authored
Oct 02, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor applications controller
parent
6f43a409
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
24 deletions
+17
-24
app/controllers/admin/applications_controller.rb
app/controllers/admin/applications_controller.rb
+6
-11
app/controllers/concerns/oauth_applications.rb
app/controllers/concerns/oauth_applications.rb
+0
-1
app/controllers/oauth/applications_controller.rb
app/controllers/oauth/applications_controller.rb
+11
-12
No files found.
app/controllers/admin/applications_controller.rb
View file @
60a1ffee
...
@@ -20,10 +20,12 @@ class Admin::ApplicationsController < Admin::ApplicationController
...
@@ -20,10 +20,12 @@ class Admin::ApplicationsController < Admin::ApplicationController
end
end
def
create
def
create
@application
=
Doorkeeper
::
Application
.
new
(
application_params
)
@application
=
Applications
::
CreateService
.
new
(
current_user
,
application_params
)
if
@application
.
save
if
@application
.
persisted?
redirect_to_admin_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
admin_application_url
(
@application
)
else
else
render
:new
render
:new
end
end
...
@@ -42,13 +44,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
...
@@ -42,13 +44,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
redirect_to
admin_applications_url
,
status:
302
,
notice:
'Application was successfully destroyed.'
redirect_to
admin_applications_url
,
status:
302
,
notice:
'Application was successfully destroyed.'
end
end
protected
def
redirect_to_admin_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
admin_application_url
(
@application
)
end
private
private
def
set_application
def
set_application
...
@@ -57,6 +52,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
...
@@ -57,6 +52,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
# Only allow a trusted parameter "white list" through.
# Only allow a trusted parameter "white list" through.
def
application_params
def
application_params
params
.
require
(
:doorkeeper_application
).
permit
(
:name
,
:redirect_uri
,
:trusted
,
:scopes
)
params
.
require
(
:doorkeeper_application
).
permit
(
:name
,
:redirect_uri
,
:trusted
,
:scopes
)
.
merge
(
ip_address:
request
.
remote_ip
)
end
end
end
end
app/controllers/concerns/oauth_applications.rb
View file @
60a1ffee
module
OauthApplications
module
OauthApplications
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
prepend
::
EE
::
Concerns
::
OauthApplications
included
do
included
do
before_action
:prepare_scopes
,
only:
[
:create
,
:update
]
before_action
:prepare_scopes
,
only:
[
:create
,
:update
]
...
...
app/controllers/oauth/applications_controller.rb
View file @
60a1ffee
...
@@ -3,7 +3,6 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
...
@@ -3,7 +3,6 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
include
Gitlab
::
GonHelper
include
Gitlab
::
GonHelper
include
PageLayoutHelper
include
PageLayoutHelper
include
OauthApplications
include
OauthApplications
prepend
::
EE
::
Oauth
::
ApplicationsController
before_action
:verify_user_oauth_applications_enabled
before_action
:verify_user_oauth_applications_enabled
before_action
:authenticate_user!
before_action
:authenticate_user!
...
@@ -17,25 +16,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
...
@@ -17,25 +16,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
end
end
def
create
def
create
@application
=
Doorkeeper
::
Application
.
new
(
application_params
)
@application
=
Applications
::
CreateService
.
new
(
current_user
,
application_params
)
@application
.
owner
=
current_user
if
@application
.
persited?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
if
@application
.
save
redirect_to
oauth_application_url
(
@application
)
redirect_to_oauth_application_page
else
else
set_index_vars
set_index_vars
render
:index
render
:index
end
end
end
end
protected
def
redirect_to_oauth_application_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
oauth_application_url
(
@application
)
end
private
private
def
verify_user_oauth_applications_enabled
def
verify_user_oauth_applications_enabled
...
@@ -62,4 +54,11 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
...
@@ -62,4 +54,11 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
render
"errors/not_found"
,
layout:
"errors"
,
status:
404
render
"errors/not_found"
,
layout:
"errors"
,
status:
404
end
end
def
application_params
super
.
tap
do
|
params
|
params
[
:owner
]
=
current_user
params
[
:ip_address
]
=
request
.
remote_ip
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