Log out everyone on startup
This commit is contained in:
@@ -61,6 +61,17 @@ public class AccountRepository {
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllLoginState(LoginState loginState) {
|
||||
String sql = """
|
||||
UPDATE account
|
||||
SET login_state = :loginState""";
|
||||
try (Handle handle = connection.getHandle()) {
|
||||
handle.createUpdate(sql)
|
||||
.bind("loginState", loginState.getValue())
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
public Integer insert(Account account) {
|
||||
String sql = """
|
||||
INSERT INTO account (name, password, birthdate, chr_slots, login_state)
|
||||
|
||||
@@ -731,7 +731,7 @@ public class Server {
|
||||
|
||||
final int worldCount = Math.min(GameConstants.WORLD_NAMES.length, YamlConfig.config.server.WORLDS);
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
setAllLoggedOut(con);
|
||||
channelDependencies.accountService().setAllLoggedOut();
|
||||
setAllMerchantsInactive(con);
|
||||
cleanNxcodeCoupons(con);
|
||||
loadCouponRates(con);
|
||||
@@ -873,12 +873,6 @@ public class Server {
|
||||
return loginServer;
|
||||
}
|
||||
|
||||
private static void setAllLoggedOut(Connection con) throws SQLException {
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE accounts SET loggedin = 0")) {
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setAllMerchantsInactive(Connection con) throws SQLException {
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0")) {
|
||||
ps.executeUpdate();
|
||||
|
||||
@@ -95,6 +95,10 @@ public class AccountService {
|
||||
return accountRepository.findByChrNameIgnoreCase(chrName);
|
||||
}
|
||||
|
||||
public void setAllLoggedOut() {
|
||||
accountRepository.setAllLoginState(LoginState.LOGGED_OUT);
|
||||
}
|
||||
|
||||
public boolean acceptTos(int accountId) {
|
||||
acceptTosMysql(accountId);
|
||||
acceptTosPostgres(accountId);
|
||||
|
||||
Reference in New Issue
Block a user