module HammerCLIForeman::Authenticate::Login

Public Instance Methods

execute_with_params(auth_type, *args) click to toggle source
# File lib/hammer_cli_foreman/authenticate/login.rb, line 4
def execute_with_params(auth_type, *args)
  connection = HammerCLIForeman.foreman_api_reconnect(auth_type)
  if !(connection.authenticator.is_a?(HammerCLIForeman::Api::SessionAuthenticatorWrapper))
    HammerCLI.interactive_output.say(_("Can't perform login. Make sure sessions are enabled in hammer"\
      " configuration file."))
    return HammerCLI::EX_USAGE
  end
  connection.authenticator.set_auth_params(*args)
  connection.authenticator.force_user_change
  connection.login

  HammerCLI.interactive_output.say(_("Successfully logged in as '%s'.") %
    connection.authenticator.user)
  HammerCLI::EX_OK
end