diff options
author | James Lopez <james@jameslopez.es> | 2017-10-24 09:38:06 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-10-31 09:03:59 +0100 |
commit | 72b7b10d52de1b150b124c017427b2802b4193e6 (patch) | |
tree | 8f38106c35e4379cc466caca7b40411749fc829c /app/controllers/oauth | |
parent | bba020a56cbedd6403b637ec7f9eaee258eb7c67 (diff) | |
download | gitlab-ce-72b7b10d52de1b150b124c017427b2802b4193e6.tar.gz |
add applications controller logic
Diffstat (limited to 'app/controllers/oauth')
-rw-r--r-- | app/controllers/oauth/applications_controller.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index b02e64a132b..daba161a177 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -16,25 +16,16 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController end def create - @application = Doorkeeper::Application.new(application_params) + @application = Applications::CreateService.new(current_user, create_application_params).execute - @application.owner = current_user - - if @application.save - redirect_to_oauth_application_page + if @application.persisted? + flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) else set_index_vars render :index 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 def verify_user_oauth_applications_enabled @@ -61,4 +52,11 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController rescue_from ActiveRecord::RecordNotFound do |exception| render "errors/not_found", layout: "errors", status: 404 end + + def create_application_params + application_params.tap do |params| + params[:owner] = current_user + params[:ip_address] = request.remote_ip + end + end end |