end
end
if needupdate.length > 0
- u.update_attributes!(needupdate)
+ begin
+ u.update_attributes!(needupdate)
+ rescue ActiveRecord::RecordInvalid
+ loginCluster = Rails.configuration.Login.LoginCluster
+ if u.uuid[0..4] == loginCluster && !needupdate[:username].nil?
+ local_user = User.find_by_username(needupdate[:username])
+ # A cached user record from the LoginCluster is stale, reset its username
+ # and retry the update operation.
+ if local_user.andand.uuid[0..4] == loginCluster && local_user.uuid != u.uuid
+ new_username = "#{needupdate[:username]}conflict#{rand(99999999)}"
+ Rails.logger.warn("cached username '#{needupdate[:username]}' collision with user '#{local_user.uuid}' - renaming to '#{new_username}' before retrying")
+ local_user.update_attributes!({username: new_username})
+ retry
+ end
+ end
+ raise # Not the issue we're handling above
+ end
end
@objects << u
end
return super if @read_users.any?(&:is_admin)
if params[:uuid] != current_user.andand.uuid
# Non-admin index/show returns very basic information about readable users.
- safe_attrs = ["uuid", "is_active", "email", "first_name", "last_name", "username"]
+ safe_attrs = ["uuid", "is_active", "email", "first_name", "last_name", "username", "can_write", "can_manage"]
if @select
@select = @select & safe_attrs
else