mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Потенциальные NPE
This commit is contained in:
parent
32d7ca932a
commit
438133bce7
4 changed files with 26 additions and 5 deletions
|
@ -57,6 +57,13 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
|
|||
throw new AuthException("Password decryption error");
|
||||
}
|
||||
}
|
||||
if(clientData.isAuth) {
|
||||
if(LogHelper.isDevEnabled()) {
|
||||
LogHelper.warning("Client %s double auth", clientData.username == null ? ip : clientData.username);
|
||||
}
|
||||
sendError("You are already logged in");
|
||||
return;
|
||||
}
|
||||
AuthProviderPair pair;
|
||||
if (auth_id == null || auth_id.isEmpty()) pair = server.config.getAuthProviderPair();
|
||||
else pair = server.config.getAuthProviderPair(auth_id);
|
||||
|
|
|
@ -25,6 +25,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
|||
sendError("Permissions denied");
|
||||
return;
|
||||
}
|
||||
if(username == null || accessToken == null || serverID == null) {
|
||||
sendError("Invalid request");
|
||||
return;
|
||||
}
|
||||
boolean success;
|
||||
try {
|
||||
server.authHookManager.joinServerHook.hook(this, client);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent;
|
||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
@ -20,14 +21,19 @@ public String getType() {
|
|||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
|
||||
if(list == null) {
|
||||
sendError("Invalid request");
|
||||
return;
|
||||
}
|
||||
result.playerProfiles = new PlayerProfile[list.length];
|
||||
for (int i = 0; i < list.length; ++i) {
|
||||
UUID uuid;
|
||||
if (client.auth == null) {
|
||||
LogHelper.warning("Client auth is null. Using default.");
|
||||
uuid = server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username);
|
||||
} else uuid = client.auth.handler.usernameToUUID(list[i].username);
|
||||
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(uuid, list[i].username, list[i].client, client.auth.textureProvider);
|
||||
AuthProviderPair pair = client.auth;
|
||||
if (pair == null) {
|
||||
pair = server.config.getAuthProviderPair();
|
||||
}
|
||||
uuid = pair.handler.usernameToUUID(list[i].username);
|
||||
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(uuid, list[i].username, list[i].client, pair.textureProvider);
|
||||
}
|
||||
sendResult(result);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
|||
sendError("Access denied");
|
||||
return;
|
||||
}
|
||||
if(dirName == null) {
|
||||
sendError("Invalid request");
|
||||
return;
|
||||
}
|
||||
HashedDir dir = server.updatesDirMap.get(dirName);
|
||||
if (dir == null) {
|
||||
sendError(String.format("Directory %s not found", dirName));
|
||||
|
|
Loading…
Reference in a new issue