Class: Users::CreateService

Inherits:
BaseService show all
Includes:
NewUserNotifier
Defined in:
app/services/users/create_service.rb

Direct Known Subclasses

AuthorizedCreateService

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from NewUserNotifier

#notify_new_user

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(current_user, params = {}) ⇒ CreateService

Returns a new instance of CreateService.



7
8
9
10
# File 'app/services/users/create_service.rb', line 7

def initialize(current_user, params = {})
  @current_user = current_user
  @params = params.dup
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
# File 'app/services/users/create_service.rb', line 12

def execute
  user = build_class.new(current_user, params).execute
  reset_token = user.generate_reset_token if user.recently_sent_password_reset?

  after_create_hook(user, reset_token) if user.save

  user
end