瀏覽代碼

Bugfix. Don't save the session if we aren't authenticated.

Also, fixed reg form cancelation.
JC Brand 10 年之前
父節點
當前提交
ca552f3440
共有 1 個文件被更改,包括 7 次插入9 次删除
  1. 7 9
      converse.js

+ 7 - 9
converse.js

@@ -508,7 +508,7 @@
             this.session.browserStorage = new Backbone.BrowserStorage[converse.storage](id);
             this.session.browserStorage = new Backbone.BrowserStorage[converse.storage](id);
             this.session.fetch();
             this.session.fetch();
             $(window).on('beforeunload', $.proxy(function () {
             $(window).on('beforeunload', $.proxy(function () {
-                if (converse.connection.connected) {
+                if (converse.connection.authenticated) {
                     this.setSession();
                     this.setSession();
                 } else {
                 } else {
                     this.clearSession();
                     this.clearSession();
@@ -4671,8 +4671,8 @@
                 });
                 });
                 $form.append('<input type="submit" class="submit" value="'+__('Register')+'"/>');
                 $form.append('<input type="submit" class="submit" value="'+__('Register')+'"/>');
                 $form.append('<input type="button" class="submit" value="'+__('Cancel')+'"/>');
                 $form.append('<input type="button" class="submit" value="'+__('Cancel')+'"/>');
-                $form.on('submit', $.proxy(this.onRegister, this));
-                $form.find('input[type=button]').on('click', $.proxy(this.onCancel, this));
+                $form.on('submit', $.proxy(this.submitRegistrationForm, this));
+                $form.find('input[type=button]').on('click', $.proxy(this.cancelRegistration, this));
             },
             },
 
 
             reportErrors: function (stanza) {
             reportErrors: function (stanza) {
@@ -4708,17 +4708,15 @@
                 $flash.show();
                 $flash.show();
             },
             },
 
 
-            cancel: function (ev) {
-                /* Callback method, when the user cancels the registration
-                 * form.
+            cancelRegistration: function (ev) {
+                /* Handler, when the user cancels the registration form.
                  */
                  */
                 if (ev && ev.preventDefault) { ev.preventDefault(); }
                 if (ev && ev.preventDefault) { ev.preventDefault(); }
                 this.render(); // XXX: check if this works.
                 this.render(); // XXX: check if this works.
             },
             },
 
 
-            onRegister: function (ev) {
-                /* Callback method, when the user submits the registration
-                 * form.
+            submitRegistrationForm : function (ev) {
+                /* Handler, when the user submits the registration form.
                  * Provides form error feedback or starts the registration
                  * Provides form error feedback or starts the registration
                  * process.
                  * process.
                  *
                  *