Class: Users::UpdateService
- Inherits:
-
BaseService
- Object
- BaseService
- Users::UpdateService
- Includes:
- NewUserNotifier
- Defined in:
- app/services/users/update_service.rb
Constant Summary collapse
- ATTRS_REQUIRING_PASSWORD_CHECK =
%w[email].freeze
- BATCH_SIZE =
100
Instance Attribute Summary collapse
-
#identity_params ⇒ Object
readonly
Returns the value of attribute identity_params.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute(validate: true, check_password: false) {|@user| ... } ⇒ Object
- #execute!(*args, **kargs, &block) ⇒ Object
-
#initialize(current_user, params = {}) ⇒ UpdateService
constructor
A new instance of UpdateService.
Methods included from NewUserNotifier
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
Constructor Details
#initialize(current_user, params = {}) ⇒ UpdateService
Returns a new instance of UpdateService.
11 12 13 14 15 16 17 18 |
# File 'app/services/users/update_service.rb', line 11 def initialize(current_user, params = {}) @current_user = current_user @validation_password = params.delete(:validation_password) @user = params.delete(:user) @status_params = params.delete(:status) @identity_params = params.slice(*identity_attributes) @params = params.dup end |
Instance Attribute Details
#identity_params ⇒ Object (readonly)
Returns the value of attribute identity_params.
6 7 8 |
# File 'app/services/users/update_service.rb', line 6 def identity_params @identity_params end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'app/services/users/update_service.rb', line 6 def user @user end |
Instance Method Details
#execute(validate: true, check_password: false) {|@user| ... } ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/users/update_service.rb', line 20 def execute(validate: true, check_password: false, &block) yield(@user) if block user_exists = @user.persisted? @user.user_detail # prevent assignment discard_read_only_attributes assign_attributes if check_password && require_password_check? && !@user.valid_password?(@validation_password) return error(s_("Profiles|Invalid password")) end assign_identity build_canonical_email reset_unconfirmed_email if @user.save(validate: validate) && update_status after_update(user_exists) else = @user.errors. + Array(@user.status&.errors&.) error(.uniq.join('. ')) end end |
#execute!(*args, **kargs, &block) ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/services/users/update_service.rb', line 45 def execute!(*args, **kargs, &block) result = execute(*args, **kargs, &block) raise ActiveRecord::RecordInvalid, @user unless result[:status] == :success true end |