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 78401bc6..5829d69c 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 @@ -166,14 +166,14 @@ public void init(LaunchServer server) { queryByUsernameSQL = customQueryByUsernameSQL != null ? customQueryByUsernameSQL : String.format("SELECT %s FROM %s WHERE %s=? LIMIT 1", userInfoCols, table, usernameColumn); queryByLoginSQL = customQueryByLoginSQL != null ? customQueryByLoginSQL : queryByUsernameSQL; - - queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL : String.format("SELECT (%s) FROM %s WHERE %s=?", - permissionsPermissionColumn, permissionsTable, permissionsUUIDColumn); - updateAuthSQL = customUpdateAuthSQL != null ? customUpdateAuthSQL : String.format("UPDATE %s SET %s=?, %s=NULL WHERE %s=?", table, accessTokenColumn, serverIDColumn, uuidColumn); updateServerIDSQL = customUpdateServerIdSQL != null ? customUpdateServerIdSQL : String.format("UPDATE %s SET %s=? WHERE %s=?", table, serverIDColumn, uuidColumn); + if(isEnabledPermissions()) { + queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL : String.format("SELECT (%s) FROM %s WHERE %s=?", + permissionsPermissionColumn, permissionsTable, permissionsUUIDColumn); + } } protected boolean updateAuth(User user, String accessToken) throws IOException { @@ -212,7 +212,7 @@ public void close() throws IOException { private SQLUser constructUser(ResultSet set) throws SQLException { return set.next() ? new SQLUser(UUID.fromString(set.getString(uuidColumn)), set.getString(usernameColumn), - set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), requestPermissions(set.getString(uuidColumn))) : null; + set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), isEnabledPermissions() ? requestPermissions(set.getString(uuidColumn)) : new ClientPermissions()) : null; } public ClientPermissions requestPermissions (String uuid) throws SQLException @@ -232,6 +232,10 @@ public ClientPermissions requestPermissions (String uuid) throws SQLException } } + public boolean isEnabledPermissions() { + return permissionsTable != null && permissionsPermissionColumn != null && permissionsUUIDColumn != null; + } + private User query(String sql, String value) throws IOException { try (Connection c = getSQLConfig().getConnection()) { PreparedStatement s = c.prepareStatement(sql);