From b9a838bf187b95e97de3c9f595a88697117217cd Mon Sep 17 00:00:00 2001 From: Christian Kittel Date: Sat, 5 Feb 2022 21:21:51 +0100 Subject: [PATCH] Fixing Issue if server returns not 200 while signing in (#12211) Signed-off-by: EvilPingu --- .../internal/services/SignInService.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java b/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java index 176ac61af..d23cb7f80 100644 --- a/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java +++ b/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java @@ -73,17 +73,19 @@ public class SignInService { connectionLosed.run(); return; } - if (result.getResponse().getStatus() != 200) { - unauthorized.run(); + if (result.getResponse().getStatus() == 200) { + PostSignInResponseModel signInModel = gson.fromJson(getContentAsString(), + PostSignInResponseModel.class); + if (signInModel == null || signInModel.errorCode != 0 || signInModel.sessionId.equals("")) { + unauthorized.run(); + return; + } + signInDone.accept(signInModel.sessionId); return; } - PostSignInResponseModel signInModel = gson.fromJson(getContentAsString(), - PostSignInResponseModel.class); - if (signInModel == null || signInModel.errorCode != 0 || signInModel.sessionId.equals("")) { - unauthorized.run(); - return; - } - signInDone.accept(signInModel.sessionId); + + connectionLosed.run(); + return; } }); }