Skip to content

Commit

Permalink
auth fix: init store the admin password can't be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
coderzc committed Mar 22, 2021
1 parent cdf5640 commit 8425915
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,25 @@ private void initAdminUser() throws Exception {
}

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

@Override
Expand Down

0 comments on commit 8425915

Please sign in to comment.