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

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

35 lines
739 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Users
class CreateService < BaseService
2017-09-10 17:25:29 +05:30
include NewUserNotifier
2017-08-17 22:00:37 +05:30
def initialize(current_user, params = {})
@current_user = current_user
@params = params.dup
end
2021-09-04 01:27:46 +05:30
def execute
user = build_class.new(current_user, params).execute
2020-03-13 15:44:24 +05:30
reset_token = user.generate_reset_token if user.recently_sent_password_reset?
2017-08-17 22:00:37 +05:30
2020-03-13 15:44:24 +05:30
after_create_hook(user, reset_token) if user.save
2017-08-17 22:00:37 +05:30
user
end
2020-03-13 15:44:24 +05:30
private
def after_create_hook(user, reset_token)
notify_new_user(user, reset_token)
end
2021-09-04 01:27:46 +05:30
def build_class
# overridden by inheriting classes
Users::BuildService
end
2017-08-17 22:00:37 +05:30
end
end
2020-03-13 15:44:24 +05:30
2021-06-08 01:23:25 +05:30
Users::CreateService.prepend_mod_with('Users::CreateService')