2018-07-18 12:03:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-27 05:37:24 -04:00
|
|
|
module Users
|
|
|
|
class CreateService < BaseService
|
2017-08-25 19:15:43 -04:00
|
|
|
include NewUserNotifier
|
|
|
|
|
2017-03-27 05:37:24 -04:00
|
|
|
def initialize(current_user, params = {})
|
|
|
|
@current_user = current_user
|
|
|
|
@params = params.dup
|
|
|
|
end
|
|
|
|
|
2017-04-24 17:12:14 -04:00
|
|
|
def execute(skip_authorization: false)
|
|
|
|
user = Users::BuildService.new(current_user, params).execute(skip_authorization: skip_authorization)
|
2017-04-13 04:47:52 -04:00
|
|
|
|
|
|
|
@reset_token = user.generate_reset_token if user.recently_sent_password_reset?
|
2017-03-27 05:37:24 -04:00
|
|
|
|
2017-08-25 19:15:43 -04:00
|
|
|
notify_new_user(user, @reset_token) if user.save
|
2017-03-27 05:37:24 -04:00
|
|
|
|
|
|
|
user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|