[ARVADOS] updated: c808c34df9a699491f745f5666b787788a649a16

git at public.curoverse.com git at public.curoverse.com
Fri Aug 22 16:02:45 EDT 2014


Summary of changes:
 services/api/app/models/user.rb | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

       via  c808c34df9a699491f745f5666b787788a649a16 (commit)
      from  d9cfb1a387937e93cd9c194273c1f03da4664b4d (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 c808c34df9a699491f745f5666b787788a649a16
Author: radhika <radhika at curoverse.com>
Date:   Fri Aug 22 16:02:19 2014 -0400

    3153: fix the while loop logic.

diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 04bf681..b3c88f5 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -455,22 +455,17 @@ 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 orig_username
-    username = String.new orig_username
-    10000.times do |count|
+  def derive_unique_username username
+    while true
       if Repository.where(name: username).empty?
         login_collisions = Link.where(link_class: 'permission',
                                       name: 'can_login').select do |perm|
           perm.properties['username'] == username
         end
-        if login_collisions.empty?
-          return username
-        end
+        return username if login_collisions.empty?
       end
-
-      username = orig_username + SecureRandom.random_number(1000).to_s
+      username = username + SecureRandom.random_number(10).to_s
     end
-    return nil  # count expired and no unused username was available
   end
 
   # Send notification if the user saved profile for the first time

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list