Commit 20e045b1 authored by Rajendra Kadam's avatar Rajendra Kadam

Change initializer in KeyService

parent b35739d8
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
module Keys module Keys
class CreateService < ::Keys::BaseService class CreateService < ::Keys::BaseService
def initialize(current_user, params = {})
@current_user, @params, @user = current_user, params, params.delete(:user)
@ip_address = @params.delete(:ip_address)
end
def execute def execute
key = user.keys.create(params) key = user.keys.create(params)
notification_service.new_key(key) if key.persisted? notification_service.new_key(key) if key.persisted?
......
...@@ -264,7 +264,7 @@ module API ...@@ -264,7 +264,7 @@ module API
user = User.find_by(id: params.delete(:id)) user = User.find_by(id: params.delete(:id))
not_found!('User') unless user not_found!('User') unless user
key = ::Keys::CreateService.new(user, declared_params(include_missing: false)).execute key = ::Keys::CreateService.new(current_user, declared_params(include_missing: false).merge(user: user)).execute
if key.persisted? if key.persisted?
present key, with: Entities::SSHKey present key, with: Entities::SSHKey
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment