Sha256: d922e67344c806c13bac338a386e4168bb45e6b95f99dd6dcbc1b6a122ef8b7b
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require 'highline/import' module HammerCLIForeman module Api class InteractiveBasicAuth < ApipieBindings::Authenticators::BasicAuth def authenticate(request, args) if HammerCLI.interactive? get_user get_password end super end def error(ex) return UnauthorizedError.new(_("Invalid username or password")) if ex.is_a?(RestClient::Unauthorized) end def status unless @user.nil? || @password.nil? _("You are logged in as '%s'") % @user else _("You are currently not logged in") end end def user @user end private def get_user @user ||= ask_user(_("[Foreman] Username: ")) end def get_password @password ||= ask_user(_("[Foreman] Password for %s: ") % @user, true) end def ask_user(prompt, silent=false) if silent ask(prompt) {|q| q.echo = false} else ask(prompt) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hammer_cli_foreman-0.10.2 | lib/hammer_cli_foreman/api/interactive_basic_auth.rb |
hammer_cli_foreman-0.10.1 | lib/hammer_cli_foreman/api/interactive_basic_auth.rb |