X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/928c037807412765259982b0a2f520ab83114c59..eda00143401effca0bbc0b2f6e4fde8ee2ede8a0:/services/api/script/create_superuser_token.rb diff --git a/services/api/script/create_superuser_token.rb b/services/api/script/create_superuser_token.rb index d119f8a887..7a2682af46 100755 --- a/services/api/script/create_superuser_token.rb +++ b/services/api/script/create_superuser_token.rb @@ -6,30 +6,10 @@ # # Print the token on stdout. -supplied_token = ARGV[0] - -require File.dirname(__FILE__) + '/../config/boot' -require File.dirname(__FILE__) + '/../config/environment' - -include ApplicationHelper -act_as_system_user +require './lib/create_superuser_token' +include CreateSuperUserToken -if supplied_token - api_client_auth = ApiClientAuthorization. - where(api_token: supplied_token). - first - if api_client_auth && !api_client_auth.user.uuid.match(/-000000000000000$/) - raise ActiveRecord::RecordNotUnique("Token already exists but is not a superuser token.") - end -end - -if !api_client_auth - api_client_auth = ApiClientAuthorization. - new(user: system_user, - api_client_id: 0, - created_by_ip_address: '::1', - api_token: supplied_token) - api_client_auth.save! -end +supplied_token = ARGV[0] -puts api_client_auth.api_token +token = CreateSuperUserToken.create_superuser_token supplied_token +puts token