Changed the order of code in CommandLineController to allow login when no database is present yet. Duh.

This commit is contained in:
Fabian Schlenz 2017-12-06 06:09:45 +01:00
parent 5328df65b3
commit 9693371a3d
1 changed files with 14 additions and 7 deletions

View File

@ -79,8 +79,7 @@ public class CommandLineController {
try {
logger.info("Initializing UserManager");
UserManager.init(client);
Database.init(client);
UserManager user = UserManager.getInstance();
if (!CommandLineOptions.cmd_login && !user.isLoggedIn()) {
@ -93,7 +92,19 @@ public class CommandLineController {
throw new RuntimeException("Account / User mismatch");
}
}
logger.debug("CommandLineOptions.cmd_login: {}", CommandLineOptions.cmd_login);
if (CommandLineOptions.cmd_login) {
cmd_login(account);
System.exit(0);
}
// If we reach this point, we can assume that there is an account and a database can be loaded / created.
Database.init(client);
if (CommandLineOptions.cmd_stats) {
cmd_stats();
System.exit(0);
@ -120,11 +131,7 @@ public class CommandLineController {
}
}
logger.debug("CommandLineOptions.cmd_login: {}", CommandLineOptions.cmd_login);
if (CommandLineOptions.cmd_login) {
cmd_login(account);
System.exit(0);
}
if (user.isLoggedIn()) {
System.out.println("You are logged in as " + Utils.anonymize(user.getUserString()));