Skip to content
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

auth fix: init store password must be not empty #1400

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,24 @@ private void initAdminUser() throws Exception {
}

private String inputPassword() {
String prompt = "Please input the admin password:";
String inputPrompt = "Please input the admin password:";
String notEmptyPrompt = "The admin password can't be empty";
Console console = System.console();
if (console != null) {
char[] chars = console.readPassword(prompt);
return new String(chars);
} else {
System.out.print(prompt);
@SuppressWarnings("resource") // just wrapper of System.in
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
while (true) {
String password = "";
if (console != null) {
char[] chars = console.readPassword(inputPrompt);
password = new String(chars);
} else {
System.out.print(inputPrompt);
@SuppressWarnings("resource") // just wrapper of System.in
Scanner scanner = new Scanner(System.in);
password = scanner.nextLine();
}
if (!password.isEmpty()) {
return password;
}
System.out.println(notEmptyPrompt);
}
}

Expand Down