class HammerCLIForeman::Api::InteractiveBasicAuth
Public Instance Methods
authenticate(request, args)
click to toggle source
Calls superclass method
# File lib/hammer_cli_foreman/api/interactive_basic_auth.rb, line 6 def authenticate(request, args) if HammerCLI.interactive? get_user get_password end super end
error(ex)
click to toggle source
# File lib/hammer_cli_foreman/api/interactive_basic_auth.rb, line 14 def error(ex) return UnauthorizedError.new(_("Invalid username or password")) if ex.is_a?(RestClient::Unauthorized) end
status()
click to toggle source
# File lib/hammer_cli_foreman/api/interactive_basic_auth.rb, line 18 def status unless @user.nil? || @password.nil? _("You are logged in as '%s'") % @user else _("You are currently not logged in") end end
user()
click to toggle source
# File lib/hammer_cli_foreman/api/interactive_basic_auth.rb, line 26 def user @user end
Private Instance Methods
ask_user(prompt, silent=false)
click to toggle source
# File lib/hammer_cli_foreman/api/interactive_basic_auth.rb, line 40 def ask_user(prompt, silent=false) if silent ask(prompt) {|q| q.echo = false} else ask(prompt) end end
get_password()
click to toggle source
# File lib/hammer_cli_foreman/api/interactive_basic_auth.rb, line 36 def get_password @password ||= ask_user(_("[Foreman] Password for %s: ") % @user, true) end
get_user()
click to toggle source
# File lib/hammer_cli_foreman/api/interactive_basic_auth.rb, line 32 def get_user @user ||= ask_user(_("[Foreman] Username: ")) end