Class: VMC::Start::Login
- Defined in:
- lib/vmc/cli/start/login.rb
Instance Method Summary collapse
Methods inherited from Base
#displayed_target?, #precondition
Methods inherited from CLI
#check_logged_in, #check_target, #client, client, client=, #client_target, #color_enabled?, #default_action, #ensure_config_dir, #err, #execute, #fail, #force?, #invalidate_client, #log_error, #name_list, #no_v2, #one_of, #precondition, #quiet?, #remove_target_info, #sane_target_url, #save_target_info, #save_targets, #set_target, #table, #target_file, #target_info, #targets_info, #tokens_file, #user_colors, #v2?, #verbose?
Methods included from VMC::Spacing
#indented, #justify, #line, #lines, #quiet?, #spaced, #start_line, #tabular, #text_width, #trim_escapes
Methods included from Interactive
#ask, #handler, #input_state, #list_choices, #prompt, #show_default
Instance Method Details
#login ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/vmc/cli/start/login.rb', line 21 def login show_context credentials = { :username => input[:username], :password => input[:password] } prompts = client.login_prompts # ask username first if prompts.key? :username type, label = prompts.delete :username credentials[:username] ||= ask_prompt(type, label) end info = target_info authenticated = false failed = false remaining_attempts = 3 until authenticated || remaining_attempts <= 0 remaining_attempts -= 1 unless force? ask_prompts(credentials, prompts) end with_progress("Authenticating") do |s| begin info[:token] = client.login(credentials) authenticated = true rescue CFoundry::Denied return if force? s.fail do failed = true credentials.delete(:password) end end end end save_target_info(info) invalidate_client if v2? line if input.interactive?(:organization) || input.interactive?(:space) select_org_and_space(input, info) save_target_info(info) end ensure exit_status 1 if not authenticated end |