Class: FaaStRuby::Command::Account::AccountBaseCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- FaaStRuby::Command::Account::AccountBaseCommand
show all
- Defined in:
- lib/faastruby/cli/commands/account/base_command.rb
Instance Method Summary
collapse
Methods inherited from BaseCommand
#has_user_logged_in?, #help, #load_credentials, #load_yaml, #say, spin, #spin, #write_file
Instance Method Details
#password_is_confirmed?(password, password_confirmation) ⇒ Boolean
11
12
13
14
15
|
# File 'lib/faastruby/cli/commands/account/base_command.rb', line 11
def password_is_confirmed?(password, password_confirmation)
return false if password.nil?
password == password_confirmation
end
|
#password_is_valid?(password) ⇒ Boolean
17
18
19
|
# File 'lib/faastruby/cli/commands/account/base_command.rb', line 17
def password_is_valid?(password)
password.match(PASSWORD_REGEX)
end
|
#prompt(command:, label:, secure: true) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/faastruby/cli/commands/account/base_command.rb', line 21
def prompt(command:, label:, secure: true)
puts ""
puts "#{command}"
print label
if secure
STDIN.noecho(&:gets).chomp
else
STDIN.gets.chomp
end
end
|
#prompt_for_password ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/faastruby/cli/commands/account/base_command.rb', line 33
def prompt_for_password
password = prompt(command: "\nNow type in a password. It must contain 8 to 50 characters and have at least one uppercase letter, one lowercase letter, one number and one special character @ $ ! % * ? &",
label: "Password: ")
until password_is_valid?(password) do
password = prompt(command: "\nYour password must contain 8 to 50 characters and have at least one uppercase letter, one lowercase letter, one number and one special character @ $ ! % * ? &\nPlease try again.".red,
label: "Password: ")
end
password
end
|
#prompt_to_confirm_password(password) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/faastruby/cli/commands/account/base_command.rb', line 45
def prompt_to_confirm_password(password)
password_confirmation = prompt(command: "\nNow type that password again",
label: "Confirm password: ")
until password_is_confirmed?(password, password_confirmation)
print "\n\nHmm... those passwords did not match. Let's try again".red
password = prompt_for_password
password_confirmation = prompt(command: "\nNow type that password again",
label: "Confirm password: ")
end
end
|