From 30fbbd942d9263f77824a892aa71e10cbff0e0f7 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 21 Sep 2019 04:11:08 +0000 Subject: [PATCH] Bugfix in login check --- .../java/iudx/http/HttpServerVerticle.java | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/iudx-api-server/src/main/java/iudx/http/HttpServerVerticle.java b/iudx-api-server/src/main/java/iudx/http/HttpServerVerticle.java index 6c8b7bdd..2fff79ad 100644 --- a/iudx-api-server/src/main/java/iudx/http/HttpServerVerticle.java +++ b/iudx-api-server/src/main/java/iudx/http/HttpServerVerticle.java @@ -3817,29 +3817,47 @@ public void publish(HttpServerRequest req) if(!pool.containsKey(id + ":" + apikey)) { + logger.debug("Pool does not contain key"); checkLogin(id, apikey) .setHandler(login -> { - if(!login.succeeded()) - { - forbidden(resp); - return; - } + if(!login.succeeded()) + { + forbidden(resp); + return; + } + + try + { + getChannel(id, apikey).basicPublish(exchange, topic, null, message.getBytes()); + } + catch(Exception e) + { + error(resp, "Could not publish to broker"); + return; + } + + accepted(resp); + return; }); } - - try - { - getChannel(id, apikey).basicPublish(exchange, topic, null, message.getBytes()); - } - catch(Exception e) + else { - error(resp, "Could not publish to broker"); + try + { + getChannel(id, apikey).basicPublish(exchange, topic, null, message.getBytes()); + } + catch(Exception e) + { + error(resp, "Could not publish to broker"); + return; + } + + accepted(resp); return; + } - accepted(resp); - return; }); }