Merge branch '18635-remove-unnecesary-.psql-management'
[arvados.git] / services / api / lib / tasks / manage_long_lived_tokens.rake
index 8700f20f5966422867646f6e736be52d09e55659..7a665ff7e77d81eee221534a547591d5750ac1b6 100644 (file)
@@ -17,6 +17,7 @@ namespace :db do
     end
     if lifetime.nil? or lifetime == 0
       puts("No expiration policy set (API.MaxTokenLifetime nor Login.TokenLifetime is set), nothing to do.")
+      # abort the rake task
       next
     end
     exp_date = Time.now + lifetime
@@ -25,9 +26,10 @@ namespace :db do
     ll_tokens(lifetime).each do |auth|
       if auth.user.nil?
         printf("*** WARNING, found ApiClientAuthorization with invalid user: auth id: %d, user id: %d\n", auth.id, auth.user_id)
+        # skip this token
         next
       end
-      if (auth.user.uuid =~ /-tpzed-000000000000000/).nil?
+      if (auth.user.uuid =~ /-tpzed-000000000000000/).nil? and (auth.user.uuid =~ /-tpzed-anonymouspublic/).nil?
         CurrentApiClientHelper.act_as_system_user do
           auth.update_attributes!(expires_at: exp_date)
         end
@@ -45,6 +47,7 @@ namespace :db do
     end
     if lifetime.nil? or lifetime == 0
       puts("No expiration policy set (API.MaxTokenLifetime nor Login.TokenLifetime is set), nothing to do.")
+      # abort the rake task
       next
     end
     user_ids = Set.new()
@@ -52,9 +55,10 @@ namespace :db do
     ll_tokens(lifetime).each do |auth|
       if auth.user.nil?
         printf("*** WARNING, found ApiClientAuthorization with invalid user: auth id: %d, user id: %d\n", auth.id, auth.user_id)
+        # skip this token
         next
       end
-      if not auth.user.nil? and (auth.user.uuid =~ /-tpzed-000000000000000/).nil?
+      if not auth.user.nil? and (auth.user.uuid =~ /-tpzed-000000000000000/).nil? and (auth.user.uuid =~ /-tpzed-anonymouspublic/).nil?
         user_ids.add(auth.user_id)
         token_count += 1
       end