From 2c8c6401301beb138a5672287e1e81b8e0f20bb1 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 8 Aug 2020 12:22:47 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9D=D0=B5=D1=81=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=BA=D0=BE=20=D1=84=D0=B8=D0=BA=D1=81=D0=BE=D0=B2=20NPE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/auth/RestoreSessionResponse.java | 1 + .../response/profile/ProfileByUUIDResponse.java | 1 - .../response/profile/ProfileByUsername.java | 15 ++++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java index db432c09..f68dfe39 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java @@ -21,6 +21,7 @@ public void execute(ChannelHandlerContext ctx, Client client) { Client rClient = server.sessionManager.getClient(session); if (rClient == null) { sendError("Session invalid"); + return; } WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class); frameHandler.setClient(rClient); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUUIDResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUUIDResponse.java index ee5d9d7c..816c5920 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUUIDResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUUIDResponse.java @@ -50,7 +50,6 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { String username; AuthProviderPair pair; if (client.auth == null) { - LogHelper.warning("Client auth is null. Using default."); pair = server.config.getAuthProviderPair(); } else { pair = client.auth; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java index 30f44bbd..61651a6d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/ProfileByUsername.java @@ -4,6 +4,7 @@ import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; +import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.utils.helper.LogHelper; import java.util.UUID; @@ -20,10 +21,14 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) throws Exception { UUID uuid; - if (client.auth == null) { - LogHelper.warning("Client auth is null. Using default."); - uuid = server.config.getAuthProviderPair().handler.usernameToUUID(username); - } else uuid = client.auth.handler.usernameToUUID(username); - sendResult(new ProfileByUsernameRequestEvent(ProfileByUUIDResponse.getProfile(uuid, username, this.client, client.auth.textureProvider))); + AuthProviderPair pair = client.auth; + if(pair == null) pair = server.config.getAuthProviderPair(); + uuid = pair.handler.usernameToUUID(username); + if(uuid == null) + { + sendError("User not found"); + return; + } + sendResult(new ProfileByUsernameRequestEvent(ProfileByUUIDResponse.getProfile(uuid, username, this.client, pair.textureProvider))); } }