-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a common method for asking for a new password #251
Add a common method for asking for a new password #251
Conversation
299176d
to
18ae029
Compare
end | ||
self.database_name = just_ask("cluster database name", database_name) | ||
self.database_user = just_ask("cluster database username", database_user) | ||
self.database_password = ask_for_new_password("cluster database password", :default => database_password, :allow_empty => true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE I'm not sure if this was intentional but the old method did allow for an empty password
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe because it has a default, allow empty allows it to use the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ManageIQ/manageiq-appliance_console/pull/251/files#diff-58f7d485041385eb768bd8d25d7e83a11ccf1a1bbf2bc4fb136fcdcf9cd6b590L126 had a default as well but that checks for a 0 length password. I think the default is only present if you've already configured a password but if this is the first time through there would be no default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was like that back to the initial open source commit.
It had a concept of no password, which I assume means the default, likely already configured with a password. I'm not sure though.
+ def ask_for_database_credentials
+ self.host = ask_for_ip_or_hostname("database hostname or IP address", host) if host.blank? || !local?
+ self.database = just_ask("name of the database on #{host}", database) unless local?
+ self.username = just_ask("username", username) unless local?
+ count = 0
+ loop do
+ count += 1
+ password1 = ask_for_password_or_none("database password on #{host}", password)
+ # if they took the default, just bail
+ break if (password1 == password)
+ password2 = ask_for_password("database password again")
+ if password1 == password2
+ self.password = password1
+ break
+ elsif count > 1 # only reprompt password once
+ raise ArgumentError, "passwords did not match"
+ else
+ say("\nThe passwords did not match, please try again")
+ end
+ end
+ end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I think I'm going to keep the behavior the same as the internal database configuration and not allow a non-default empty password.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agrare I agree 👍
18ae029
to
b0708b2
Compare
4544ca6
to
de20f41
Compare
When entering an existing password it is sufficient to prompt once since if the user mistyped the password it will fail later on, but when creating a new password it is common to re-prompt them to confirm that they didn't typo the new password.
de20f41
to
7892d83
Compare
Checked commit agrare@7892d83 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
Added - Add a common method for asking for a password [#251] - Add messaging hostname validation [#254] - Indicate that messaging persistent disk is optional [#256] - Add messaging password validation [#255] Changed - Deprecate message-server-use-ipaddr option from cli [#257] Fixed - Add ca-cert to messaging client installed_files [#258]
When entering an existing password it is sufficient to prompt once since if the user mistyped the password it will fail later on, but when creating a new password it is common to re-prompt them to confirm that they didn't typo the new password.
We had this "prompt twice, check non-empty" loop in two places and were going to need it in a third so it seemed better to move this to a common method.
TODO
Database configuration testing:
Message Server Configuration testing
Fixes ManageIQ/manageiq#23031