瀏覽代碼

Handle reconnection on authfail edge case.

Attempt reconnection on authfail when credentials_url and auto_reconnect are set.
JC Brand 8 年之前
父節點
當前提交
60f86378a4
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10 1
      src/converse-core.js

+ 10 - 1
src/converse-core.js

@@ -432,7 +432,16 @@
              * Will either start a teardown process for converse.js or attempt
              * Will either start a teardown process for converse.js or attempt
              * to reconnect.
              * to reconnect.
              */
              */
-            if (_.includes([converse.LOGOUT, Strophe.Status.AUTHFAIL], converse.disconnection_cause) ||
+            if (converse.disconnection_cause === Strophe.Status.AUTHFAIL) {
+                if (converse.credentials_url && converse.auto_reconnect) {
+                    /* In this case, we reconnect, because we might be receiving
+                     * expirable tokens from the credentials_url.
+                     */
+                    return converse.reconnect();
+                } else {
+                    return converse.disconnect();
+                }
+            } else if (converse.disconnection_cause === converse.LOGOUT ||
                     converse.disconnection_reason === "host-unknown" ||
                     converse.disconnection_reason === "host-unknown" ||
                     !converse.auto_reconnect) {
                     !converse.auto_reconnect) {
                 return converse.disconnect();
                 return converse.disconnect();