]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fixing Issue if server returns not 200 while signing in (#12211)
authorChristian Kittel <EvilPingu@users.noreply.github.com>
Sat, 5 Feb 2022 20:21:51 +0000 (21:21 +0100)
committerGitHub <noreply@github.com>
Sat, 5 Feb 2022 20:21:51 +0000 (21:21 +0100)
Signed-off-by: EvilPingu <ckittel@gmx.de>
bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java

index 176ac61af32b88010732b9c7c72b47ca7b9469bf..d23cb7f80d2657e70b08d11eb0c88c7f5112e55b 100644 (file)
@@ -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;
             }
         });
     }