From 5f7808afff9b5826c36c3d67fff143dbb1627a87 Mon Sep 17 00:00:00 2001 From: Gravita Date: Mon, 12 Dec 2022 15:14:12 +0700 Subject: [PATCH] [FIX] MySQLAuthCoreProvider --- .../launchserver/auth/core/AbstractSQLCoreProvider.java | 6 +++++- .../gravit/launchserver/auth/core/MySQLCoreProvider.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java index 914b67e0..a389f631 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java @@ -169,7 +169,7 @@ public void init(LaunchServer server) { if (serverIDColumn == null) logger.error("serverIDColumn cannot be null"); if (table == null) logger.error("table cannot be null"); // Prepare SQL queries - String userInfoCols = String.format("%s, %s, %s, %s, %s", uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, passwordColumn); + String userInfoCols = makeUserCols(); queryByUUIDSQL = customQueryByUUIDSQL != null ? customQueryByUUIDSQL : String.format("SELECT %s FROM %s WHERE %s=? LIMIT 1", userInfoCols, table, uuidColumn); queryByUsernameSQL = customQueryByUsernameSQL != null ? customQueryByUsernameSQL : String.format("SELECT %s FROM %s WHERE %s=? LIMIT 1", @@ -204,6 +204,10 @@ public void init(LaunchServer server) { } } + protected String makeUserCols() { + return String.format("%s, %s, %s, %s, %s", uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, passwordColumn); + } + protected boolean updateAuth(User user, String accessToken) throws IOException { try (Connection c = getSQLConfig().getConnection()) { SQLUser SQLUser = (SQLUser) user; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java index dc9c6467..2d6555a4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java @@ -43,7 +43,7 @@ public SQLSourceConfig getSQLConfig() { @Override public void init(LaunchServer server) { super.init(server); - String userInfoCols = String.format("%s, %s, %s, %s, %s, %s", uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, passwordColumn, hardwareIdColumn); + String userInfoCols = makeUserCols(); String hardwareInfoCols = "id, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, graphicCard, banned, publicKey"; if (sqlFindHardwareByPublicKey == null) sqlFindHardwareByPublicKey = String.format("SELECT %s FROM %s WHERE `publicKey` = ?", hardwareInfoCols, tableHWID); @@ -63,6 +63,11 @@ public void init(LaunchServer server) { sqlUpdateUsers = String.format("UPDATE %s SET `%s` = ? WHERE `%s` = ?", table, hardwareIdColumn, uuidColumn); } + @Override + protected String makeUserCols() { + return super.makeUserCols().concat(", ").concat(hardwareIdColumn); + } + @Override protected MySQLUser constructUser(ResultSet set) throws SQLException { return set.next() ? new MySQLUser(UUID.fromString(set.getString(uuidColumn)), set.getString(usernameColumn),