gitlab-org--gitlab-foss/app/services/keys/create_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
532 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-09-15 11:35:24 -04:00
module Keys
class CreateService < ::Keys::BaseService
attr_accessor :current_user
def initialize(current_user, params = {})
@current_user = current_user
@params = params
@ip_address = @params.delete(:ip_address)
@user = params.delete(:user) || current_user
end
2017-09-15 11:35:24 -04:00
def execute
key = user.keys.create(params)
notification_service.new_key(key) if key.persisted?
key
end
end
end
Keys::CreateService.prepend_mod_with('Keys::CreateService')