lib/aptible/cli/agent.rb in aptible-cli-0.16.7 vs lib/aptible/cli/agent.rb in aptible-cli-0.16.8

- old
+ new

@@ -65,10 +65,11 @@ end def initialize(*) nag_toolbelt unless toolbelt? Aptible::Resource.configure { |conf| conf.user_agent = version_string } + warn_sso_enforcement super end desc 'version', 'Print Aptible CLI version' def version @@ -228,9 +229,25 @@ ].join("\n")) FileUtils.mkdir_p(File.dirname(nag_file)) File.open(nag_file, 'w', 0o600) { |f| f.write(now.to_s) } end + end + + def warn_sso_enforcement + # If the user is also a member of + begin + token = fetch_token + rescue StandardError + return + end + reauth = Aptible::Auth::ReauthenticateOrganization.all(token: token) + return if reauth.empty? + + CLI.logger.warn(['WARNING: You will need to use the appropriate', + 'login method (SSO or Aptible credentials) to access', + 'these organizations:', + reauth.map(&:name)].join(' ')) end def version_string bits = [ 'aptible-cli',