summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2017-10-24 09:52:47 +0300
committerJames Lopez <james@jameslopez.es>2017-10-31 09:03:59 +0100
commitd0546e6d81fa3eb9424db9beb5e34d351fabb0fc (patch)
tree95a12fcf979d34b7f793c3fa3145157604e05382
parent72b7b10d52de1b150b124c017427b2802b4193e6 (diff)
downloadgitlab-ce-d0546e6d81fa3eb9424db9beb5e34d351fabb0fc.tar.gz
uypdated keys controller logic
-rw-r--r--app/controllers/profiles/keys_controller.rb10
-rw-r--r--app/services/keys/base_service.rb1
2 files changed, 3 insertions, 8 deletions
diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb
index 069e6a810f2..f0e5d2aa94e 100644
--- a/app/controllers/profiles/keys_controller.rb
+++ b/app/controllers/profiles/keys_controller.rb
@@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController
end
def create
- @key = Keys::CreateService.new(current_user, key_params).execute
+ @key = Keys::CreateService.new(current_user, key_params.merge(ip_address: request.remote_ip)).execute
if @key.persisted?
- redirect_to_profile_key_path
+ redirect_to profile_key_path(@key)
else
@keys = current_user.keys.select(&:persisted?)
render :index
@@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController
end
end
- protected
-
- def redirect_to_profile_key_path
- redirect_to profile_key_path(@key)
- end
-
private
def key_params
diff --git a/app/services/keys/base_service.rb b/app/services/keys/base_service.rb
index 545832d0bd4..f78791932a7 100644
--- a/app/services/keys/base_service.rb
+++ b/app/services/keys/base_service.rb
@@ -4,6 +4,7 @@ module Keys
def initialize(user, params)
@user, @params = user, params
+ @ip_address = @params.delete(:ip_address)
end
def notification_service