forked from stringer-rss/stringer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_password.rb
More file actions
35 lines (30 loc) · 812 Bytes
/
change_password.rb
File metadata and controls
35 lines (30 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require "highline"
require_relative "../commands/users/change_user_password"
class ChangePassword
def initialize(ui = HighLine.new, command = ChangeUserPassword.new)
@ui = ui
@command = command
end
def change_password
while (password = ask_password) != (confirmation = ask_confirmation)
@ui.say "The confirmation doesn't match the password. Please try again."
end
@command.change_user_password(password)
end
private
def ask_password
ask_hidden("New password: ") do |q|
q.validate = /\A.+\Z/
q.responses[:not_valid] = "The password can't be blank."
end
end
def ask_confirmation
ask_hidden("Confirmation: ")
end
def ask_hidden(question)
@ui.ask(question) do |q|
q.echo = "*"
yield(q) if block_given?
end
end
end