Class: FaaStRuby::Command::Account::Confirm
Class Method Summary
collapse
Instance Method Summary
collapse
#password_is_confirmed?, #password_is_valid?, #prompt, #prompt_for_password, #prompt_to_confirm_password
Methods inherited from BaseCommand
#has_user_logged_in?, #help, #load_credentials, #load_yaml, #say, spin, #spin, #write_file
Constructor Details
#initialize(args) ⇒ Confirm
Returns a new instance of Confirm.
7
8
9
10
11
12
|
# File 'lib/faastruby/cli/commands/account/confirm.rb', line 7
def initialize(args)
@args = args
parse_options
@missing_args = []
FaaStRuby::CLI.error(@missing_args, color: nil) if missing_args.any?
end
|
Class Method Details
.help ⇒ Object
54
55
56
|
# File 'lib/faastruby/cli/commands/account/confirm.rb', line 54
def self.help
"confirm-account [ARGS]"
end
|
Instance Method Details
#error(spinner: nil, errors:) ⇒ Object
33
34
35
36
|
# File 'lib/faastruby/cli/commands/account/confirm.rb', line 33
def error(spinner: nil, errors:)
spinner&.error
FaaStRuby::CLI.error(errors)
end
|
#migrate ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/faastruby/cli/commands/account/confirm.rb', line 38
def migrate
old_credentials = File.expand_path("~/.faastruby.tor1")
return unless File.file?(old_credentials)
puts "ATTENTION: I've detected you have workspace credentials saved in '#{old_credentials}'.".red
puts "You need to migrate these credentials into your account."
print "Do you want to do it right now? [Y/n] "
answer = STDIN.gets.chomp
if answer == 'n'
puts "You won't be able to manage these workspaces until you perform this migration."
puts "When you are ready to perform this migration, run 'faastruby migrate-workspaces'."
exit 0
else
exec("faastruby migrate-workspaces")
end
end
|
#run ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/faastruby/cli/commands/account/confirm.rb', line 14
def run
user = User.new(email: @options['email'])
user.send_confirmation_code
error(errors: user.errors) if user.errors.any?
puts "\nYou should have received an email with a confirmation token."
puts "If you didn't receive an email:"
puts "- Make sure you sign up with the correct email address"
puts "- The system won't send an email if you account status is already 'confirmed'"
print "Confirmation Token: "
user.confirmation_token = STDIN.gets.chomp
spinner = spin("Confirming your account...")
user.confirm_account!
error(errors: user.errors) if user.errors.any?
spinner.success
user.save_credentials
puts "Login successful!"
migrate
end
|
#usage ⇒ Object
58
59
60
61
62
63
|
# File 'lib/faastruby/cli/commands/account/confirm.rb', line 58
def usage
puts "Usage: faastruby #{self.class.help}"
puts %(
-e,--email EMAIL # Your email
)
end
|