X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b6d7efab2c4bffa3fabd55b166e44cca8ac1391f..98bd6c43fca91b76d528c8ed5b83c655c86ffe3c:/services/api/app/controllers/arvados/v1/users_controller.rb diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb index 224f2c0bd4..cd23706d08 100644 --- a/services/api/app/controllers/arvados/v1/users_controller.rb +++ b/services/api/app/controllers/arvados/v1/users_controller.rb @@ -22,7 +22,15 @@ class Arvados::V1::UsersController < ApplicationController rescue ActiveRecord::RecordNotUnique retry end - u.update_attributes!(attrs) + needupdate = {} + nullify_attrs(attrs).each do |k,v| + if !v.nil? && u.send(k) != v + needupdate[k] = v + end + end + if needupdate.length > 0 + u.update_attributes!(needupdate) + end @objects << u end @offset = 0 @@ -54,7 +62,11 @@ class Arvados::V1::UsersController < ApplicationController @object = current_user end if not @object.is_active - if not (current_user.is_admin or @object.is_invited) + if @object.uuid[0..4] == Rails.configuration.Login.LoginCluster && + @object.uuid[0..4] != Rails.configuration.ClusterID + logger.warn "Local user #{@object.uuid} called users#activate but only LoginCluster can do that" + raise ArgumentError.new "cannot activate user #{@object.uuid} here, only the #{@object.uuid[0..4]} cluster can do that" + elsif not (current_user.is_admin or @object.is_invited) logger.warn "User #{@object.uuid} called users.activate " + "but is not invited" raise ArgumentError.new "Cannot activate without being invited." @@ -249,6 +261,14 @@ class Arvados::V1::UsersController < ApplicationController } end + def self._update_requires_parameters + super.merge({ + bypass_federation: { + type: 'boolean', required: false, + }, + }) + end + def self._update_uuid_requires_parameters { new_uuid: { @@ -271,4 +291,8 @@ class Arvados::V1::UsersController < ApplicationController end super end + + def nullable_attributes + super + [:email, :first_name, :last_name, :username] + end end