Skip to content

Commit

Permalink
auth fix: init store password must be not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
coderzc committed Mar 22, 2021
1 parent 4c4b770 commit cdf5640
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +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";
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();
}
do {
if (console != null) {
char[] chars = console.readPassword(prompt);
password = new String(chars);
} else {
System.out.print(prompt);
@SuppressWarnings("resource") // just wrapper of System.in
Scanner scanner = new Scanner(System.in);
password = scanner.nextLine();
}
if (password.isEmpty()) {
System.out.println(alertMsg);
}
} while (password.isEmpty());
return password;
}

@Override
Expand Down

0 comments on commit cdf5640

Please sign in to comment.