Class: VMC::Cli::Command::User
- Inherits:
-
Base
show all
- Defined in:
- lib/cli/commands/user.rb
Constant Summary
Constants inherited
from Base
Base::MANIFEST
Instance Attribute Summary
Attributes inherited from Base
#no_prompt, #prompt_ok
Instance Method Summary
collapse
Methods inherited from Base
#auth_token, #client, #client_info, #find_in_hash, #find_symbol, #frameworks_info, #initialize, #load_manifest, #load_manifest_structure, #manifest, #manifest_file, #merge_manifest, #merge_parent, #resolve_in, #resolve_lexically, #resolve_manifest, #resolve_symbol, #runtimes_info, #target_base, #target_url
Instance Method Details
#change_password(password = nil) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/cli/commands/user.rb', line 66
def change_password(password=nil)
info = client_info
email = info[:user]
err "Need to be logged in to change password." unless email
say "Changing password for '#{email}'\n"
unless no_prompt
password = ask "New Password", :echo => "*"
password2 = ask "Verify Password", :echo => "*"
err "Passwords did not match, try again" if password != password2
end
err "Password required" unless password
client.change_password(password)
say "\nSuccessfully changed password".green
end
|
5
6
7
8
9
10
|
# File 'lib/cli/commands/user.rb', line 5
def info
info = client_info
username = info[:user] || 'N/A'
return display JSON.pretty_generate([username]) if @options[:json]
display "\n[#{username}]"
end
|
#login(email = nil) ⇒ Object
12
13
14
15
16
17
18
19
20
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
|
# File 'lib/cli/commands/user.rb', line 12
def login(email=nil)
if VMC::Cli::Config.uhuru_target
begin
token = email
token = @options[:token] unless token
unless no_prompt
display "Attempting login to Uhuru AppCloud [#{target_url}]" if target_url
token ||= ask("Token")
end
err "Need a valid authentication token" unless token
uhuru_login_and_save_token(token)
say "Successfully logged into Uhuru AppCloud [#{target_url}]".green
rescue => e
display "Problem with login to Uhuru AppCloud '#{target_url}', #{e}, try again or get a new one time token or regular authentication token.".red
exit 1
end
else
begin
email = @options[:email] unless email
password = @options[:password]
tries ||= 0
unless no_prompt
display "Attempting login to [#{target_url}]" if target_url
email ||= ask("Email")
password ||= ask("Password", :echo => "*")
end
err "Need a valid email" unless email
err "Need a password" unless password
login_and_save_token(email, password)
say "Successfully logged into [#{target_url}]".green
rescue VMC::Client::TargetError
display "Problem with login, invalid account or password when attempting to login to '#{target_url}'".red
retry if (tries += 1) < 3 && prompt_ok && !@options[:password]
exit 1
rescue => e
display "Problem with login to '#{target_url}', #{e}, try again or register for an account.".red
exit 1
end
end
end
|