瀏覽代碼

Two session related fixes.

* Don't set JID resource when logging in anonymously. The resource will be set by the server.
* Don't wipe the `id` from the session when clearing it.
JC Brand 6 年之前
父節點
當前提交
3817f471a0
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/headless/converse-core.js

+ 4 - 2
src/headless/converse-core.js

@@ -484,7 +484,8 @@ _converse.initConnection = function () {
                 )
             );
         } else {
-            throw new Error("initConnection: this browser does not support websockets and bosh_service_url wasn't specified.");
+            throw new Error("initConnection: this browser does not support "+
+                            "websockets and bosh_service_url wasn't specified.");
         }
     }
     setUpXMLLogging();
@@ -507,6 +508,7 @@ async function initUserSession (jid) {
         await new Promise(r => _converse.session.fetch({'success': r, 'error': r}));
         if (_converse.session.get('active')) {
             _converse.session.clear();
+            _converse.session.save({'id': id});
         }
         /**
          * Triggered once the user's session has been initialized. The session is a
@@ -521,7 +523,7 @@ async function initUserSession (jid) {
 async function setUserJID (jid) {
     await initUserSession(jid);
     jid = _converse.session.get('jid') || jid;
-    if (!Strophe.getResourceFromJid(jid)) {
+    if (_converse.authentication !== _converse.ANONYMOUS && !Strophe.getResourceFromJid(jid)) {
         jid = jid.toLowerCase() + _converse.generateResource();
     }
     // Set JID on the connection object so that when we call