From 1362d7178886ab611ec01635ea79086f97b87675 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 27 Aug 2020 21:28:06 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B5=D0=B7=D0=BE=D0=BF?= =?UTF-8?q?=D0=B0=D1=81=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/socket/WebSocketService.java | 1 - .../response/auth/SetPasswordResponse.java | 48 ------------------- .../management/PingServerReportResponse.java | 1 + .../request/SetPasswordRequestEvent.java | 10 ---- .../websockets/ClientWebSocketService.java | 2 +- 5 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index d9c5be81..1e50772b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -93,7 +93,6 @@ public static void registerResponses() { providers.register("profileByUUID", ProfileByUUIDResponse.class); providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class); providers.register("register", RegisterResponse.class); - providers.register("setPassword", SetPasswordResponse.class); providers.register("exit", ExitResponse.class); providers.register("getSecureLevelInfo", GetSecureLevelInfoResponse.class); providers.register("verifySecureLevelKey", VerifySecureLevelKeyResponse.class); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java deleted file mode 100644 index 0e77d64b..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -package pro.gravit.launchserver.socket.response.auth; - -import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.ClientPermissions; -import pro.gravit.launcher.events.request.SetPasswordRequestEvent; -import pro.gravit.launchserver.dao.User; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.response.SimpleResponse; - -public class SetPasswordResponse extends SimpleResponse { - public String oldPassword; - public String newPassword; - public String username; - - @Override - public String getType() { - return "setPassword"; - } - - @Override - public void execute(ChannelHandlerContext ctx, Client client) { - if ((oldPassword == null && username == null) || newPassword == null) { - sendError("Request invalid"); - return; - } - if (!client.isAuth) { - sendError("You not authorized"); - return; - } - if (username != null && !client.permissions.isPermission(ClientPermissions.PermissionConsts.ADMIN)) { - sendError("You not admin"); - return; - } - if (username != null) { - User user = server.config.dao.userDAO.findByUsername(username); - user.setPassword(newPassword); - sendResult(new SetPasswordRequestEvent()); - } else { - User user = server.config.dao.userDAO.findByUsername(client.username); - if (user.verifyPassword(oldPassword)) { - user.setPassword(newPassword); - sendResult(new SetPasswordRequestEvent()); - } else { - sendError("Old password incorrect"); - } - } - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java index 5474e83f..b0956a0c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/management/PingServerReportResponse.java @@ -20,6 +20,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { if(!client.isAuth || client.permissions == null || !client.permissions.isPermission(ClientPermissions.PermissionConsts.MANAGEMENT)) { sendError("Access denied"); + return; } server.pingServerManager.updateServer(name, data); sendResult(new PingServerReportRequestEvent()); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java deleted file mode 100644 index 96efa2c0..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetPasswordRequestEvent.java +++ /dev/null @@ -1,10 +0,0 @@ -package pro.gravit.launcher.events.request; - -import pro.gravit.launcher.events.RequestEvent; - -public class SetPasswordRequestEvent extends RequestEvent { - @Override - public String getType() { - return "setPassword"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index fb4bd479..bdf77791 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -93,7 +93,6 @@ public void registerResults() { results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); results.register("exception", ExceptionEvent.class); results.register("register", RegisterRequestEvent.class); - results.register("setpassword", SetPasswordRequestEvent.class); results.register("notification", NotificationEvent.class); results.register("signal", SignalEvent.class); results.register("exit", ExitRequestEvent.class); @@ -104,6 +103,7 @@ public void registerResults() { results.register("serverStatus", ServerStatusRequestEvent.class); results.register("pingServerReport", PingServerReportRequestEvent.class); results.register("pingServer", PingServerRequestEvent.class); + results.register("currentUser", CurrentUserRequestEvent.class); } public void waitIfNotConnected() {