diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/ProfilesResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/ProfilesResponse.java index f08f71c1..29c9581b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/ProfilesResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/ProfilesResponse.java @@ -20,6 +20,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client if(!client.isAuth) { service.sendObject(ctx, new WebSocketService.ErrorResult("Access denied")); + return; } service.sendObject(ctx, new Result((List) LaunchServer.server.getProfiles())); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/SetProfileResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/SetProfileResponse.java new file mode 100644 index 00000000..83e41ee2 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/SetProfileResponse.java @@ -0,0 +1,39 @@ +package ru.gravit.launchserver.socket.websocket.json.auth; + +import io.netty.channel.ChannelHandlerContext; +import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.socket.Client; +import ru.gravit.launchserver.socket.websocket.WebSocketService; +import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; + +import java.util.Collection; + +public class SetProfileResponse implements JsonResponseInterface { + @Override + public String getType() { + return "setProfile"; + } + + @Override + public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + if(!client.isAuth) + { + service.sendObject(ctx, new WebSocketService.ErrorResult("Access denied")); + return; + } + Collection profiles = LaunchServer.server.getProfiles(); + for (ClientProfile p : profiles) { + if (p.getTitle().equals(client)) { + if (!p.isWhitelistContains(client.username)) { + service.sendObject(ctx, new WebSocketService.ErrorResult(LaunchServer.server.config.whitelistRejectString)); + return; + } + client.profile = p; + service.sendObject(ctx, new WebSocketService.SuccessResult(getType())); + break; + } + } + service.sendObject(ctx, new WebSocketService.ErrorResult("Profile not found")); + } +}