X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/609646134bcd8fc3a7fd500848220741ecc4a9d2..c64d7e1d5d1879187e1c4002445fab1d3c7951a0:/services/api/lib/create_superuser_token.rb diff --git a/services/api/lib/create_superuser_token.rb b/services/api/lib/create_superuser_token.rb index 72b1ae7bc9..da67a32c79 100755 --- a/services/api/lib/create_superuser_token.rb +++ b/services/api/lib/create_superuser_token.rb @@ -26,15 +26,18 @@ module CreateSuperUserToken # need to create a token if !api_client_auth # Get (or create) trusted api client - apiClient = ApiClient.find_or_create_by_url_prefix_and_is_trusted("ssh://root@localhost/", true) + apiClient = ApiClient. + find_or_create_by(url_prefix: "ssh://root@localhost/", + is_trusted: true) # Check if there is an unexpired superuser token corresponding to this api client - api_client_auth = ApiClientAuthorization.where( - 'user_id = ? AND - api_client_id = ? AND - scopes = ? AND - (expires_at IS NULL OR expires_at > CURRENT_TIMESTAMP)', - system_user.id, apiClient.id, ['all'].to_yaml).first + api_client_auth = + ApiClientAuthorization. + where(user_id: system_user.id). + where(api_client_id: apiClient.id). + where_serialized(:scopes, ['all']). + where('(expires_at IS NULL OR expires_at > CURRENT_TIMESTAMP)'). + first # none exist; create one with the supplied token if !api_client_auth