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

23 lines
548 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
def execute(skip_authorization: false)
user = Users::BuildService.new(current_user, params).execute(skip_authorization: skip_authorization)
@reset_token = user.generate_reset_token if user.recently_sent_password_reset?
2017-09-10 17:25:29 +05:30
notify_new_user(user, @reset_token) if user.save
2017-08-17 22:00:37 +05:30
user
end
end
end