diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 09:08:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 09:08:10 +0300 |
commit | 6ede90f5dd63d4a1f5ba243b4ed5097bb1a0acab (patch) | |
tree | 6bb9e934cdd90d62e672a1d6c4a5a63995bfbb00 /app/services/users | |
parent | b8e30b446d9cb91b94d2b55e5c81303c8f2d1b25 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/users')
-rw-r--r-- | app/services/users/update_service.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/services/users/update_service.rb b/app/services/users/update_service.rb index 422c8ed6575..dfbb65b7fcf 100644 --- a/app/services/users/update_service.rb +++ b/app/services/users/update_service.rb @@ -17,6 +17,8 @@ module Users yield(@user) if block_given? user_exists = @user.persisted? + + discard_read_only_attributes assign_attributes assign_identity @@ -50,13 +52,28 @@ module Users success end - def assign_attributes + def discard_read_only_attributes + discard_synced_attributes + discard_name unless name_updatable? + end + + def discard_synced_attributes if (metadata = @user.user_synced_attributes_metadata) read_only = metadata.read_only_attributes params.reject! { |key, _| read_only.include?(key.to_sym) } end + end + def discard_name + params.delete(:name) + end + + def name_updatable? + can?(current_user, :update_name, @user) + end + + def assign_attributes @user.assign_attributes(params.except(*identity_attributes)) unless params.empty? end |