summaryrefslogtreecommitdiff
path: root/app/services/keys/create_service.rb
blob: c1c3ef8792f7ade3f1857f1ebd79582a4e6f30c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

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

    def execute
      key = user.keys.create(params)
      notification_service.new_key(key) if key.persisted?
      key
    end
  end
end

Keys::CreateService.prepend_if_ee('EE::Keys::CreateService')