mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Вынос настройки message в MySQLAuthProvider
This commit is contained in:
parent
f965f081db
commit
d89c976a5c
1 changed files with 3 additions and 1 deletions
|
@ -20,6 +20,7 @@
|
|||
public final class MySQLAuthProvider extends AuthProvider {
|
||||
private final MySQLSourceConfig mySQLHolder;
|
||||
private final String query;
|
||||
private final String message;
|
||||
private final String[] queryParams;
|
||||
private final boolean usePermission;
|
||||
|
||||
|
@ -31,6 +32,7 @@ public MySQLAuthProvider(BlockConfigEntry block, LaunchServer server) {
|
|||
query = VerifyHelper.verify(block.getEntryValue("query", StringConfigEntry.class),
|
||||
VerifyHelper.NOT_EMPTY, "MySQL query can't be empty");
|
||||
usePermission = block.hasEntry("usePermission") ? block.getEntryValue("usePermission", BooleanConfigEntry.class) : false;
|
||||
message = block.hasEntry("message") ? block.getEntryValue("message", StringConfigEntry.class) : "Incorrect username or password";
|
||||
queryParams = block.getEntry("queryParams", ListConfigEntry.class).
|
||||
stream(StringConfigEntry.class).toArray(String[]::new);
|
||||
}
|
||||
|
@ -46,7 +48,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
|
|||
// Execute SQL query
|
||||
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
|
||||
try (ResultSet set = s.executeQuery()) {
|
||||
return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : new ClientPermissions()) : authError("Incorrect username or password");
|
||||
return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : new ClientPermissions()) : authError(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue