[ARVADOS] updated: c5ec75eed7fec3fcb70031d684acfc7532ba9996
git at public.curoverse.com
git at public.curoverse.com
Thu Aug 21 16:00:29 EDT 2014
Summary of changes:
services/api/app/models/user.rb | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
via c5ec75eed7fec3fcb70031d684acfc7532ba9996 (commit)
from 1f438358f952fe296bd6aebaa1f868ddb366fb7e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit c5ec75eed7fec3fcb70031d684acfc7532ba9996
Author: radhika <radhika at curoverse.com>
Date: Thu Aug 21 15:43:50 2014 -0400
3153: use loop with counter than while(true) to derive unique username
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 5530eb6..b41c7e5 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -455,9 +455,11 @@ class User < ArvadosModel
# Find a username that starts with the given string and does not collide
# with any existing repository name or VM login name
- def derive_unique_username username
+ def derive_unique_username orig_username
vm_uuid = Rails.configuration.auto_setup_new_users_with_vm_uuid
- while true
+
+ username = String.new orig_username
+ 10000.times do |count|
if Repository.where(name: username).empty?
login_collisions = Link.where(head_uuid: vm_uuid,
link_class: 'permission',
@@ -468,8 +470,10 @@ class User < ArvadosModel
return username
end
end
- username = username + SecureRandom.random_number(100).to_s
+
+ username = orig_username + SecureRandom.random_number(1000).to_s
end
+ return username
end
# Send notification if the user saved profile for the first time
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list