mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] MySQL/PostgreSQL permissions
This commit is contained in:
parent
1996525b65
commit
10df931c2a
1 changed files with 9 additions and 5 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue