debian-mirror-gitlab/app/services/keys/create_service.rb

23 lines
532 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Keys
class CreateService < ::Keys::BaseService
2020-06-23 00:09:42 +05:30
attr_accessor :current_user
def initialize(current_user, params = {})
2021-04-29 21:17:54 +05:30
@current_user = current_user
@params = params
2020-06-23 00:09:42 +05:30
@ip_address = @params.delete(:ip_address)
@user = params.delete(:user) || current_user
end
2018-03-17 18:26:18 +05:30
def execute
key = user.keys.create(params)
notification_service.new_key(key) if key.persisted?
key
end
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Keys::CreateService.prepend_mod_with('Keys::CreateService')