aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-05-27 23:15:12 +0300
committerGravatar Vitaly Takmazov2018-05-27 23:15:12 +0300
commit4319a2c2de6391f3e42993e96675a64baf9f0d78 (patch)
treedea5c73163e887afcff77c90baa8c9b6d9ee94c9 /juick-server/src/main/java/com/juick
parent4080ecbdb18bf67275317bdcfa5bcc52d3ac94e4 (diff)
ws: accept commands from authenticated users
Diffstat (limited to 'juick-server/src/main/java/com/juick')
-rw-r--r--juick-server/src/main/java/com/juick/server/WebsocketManager.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/juick-server/src/main/java/com/juick/server/WebsocketManager.java b/juick-server/src/main/java/com/juick/server/WebsocketManager.java
index 85950c2c..5c976416 100644
--- a/juick-server/src/main/java/com/juick/server/WebsocketManager.java
+++ b/juick-server/src/main/java/com/juick/server/WebsocketManager.java
@@ -156,10 +156,14 @@ public class WebsocketManager extends TextWebSocketHandler {
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
User user = clients.stream().filter(c -> c.session.equals(session)).map(c -> c.visitor)
.findFirst().orElse(AnonymousUser.INSTANCE);
- String command = message.getPayload().trim();
- if (StringUtils.isNotEmpty(command)) {
- CommandResult result = commandsManager.processCommand(user, command, URI.create(""));
- session.sendMessage(new TextMessage(result.getText()));
+ if (!user.isAnonymous()) {
+ String command = message.getPayload().trim();
+ if (StringUtils.isNotEmpty(command)) {
+ CommandResult result = commandsManager.processCommand(user, command, URI.create(""));
+ session.sendMessage(new TextMessage(result.getText()));
+ }
+ } else {
+ session.sendMessage(new TextMessage("Authorization required"));
}
}