浏览代码

on-the-fly auth improvements

j8
isymchych 9 年前
父节点
当前提交
3400925f99
共有 4 个文件被更改,包括 51 次插入15 次删除
  1. 19
    4
      libs/lib-jitsi-meet.js
  2. 21
    8
      modules/AuthHandler.js
  3. 2
    1
      modules/RoomLocker.js
  4. 9
    2
      modules/UI/authentication/LoginDialog.js

+ 19
- 4
libs/lib-jitsi-meet.js 查看文件

@@ -332,7 +332,7 @@ JitsiConference.prototype.lock = function (password) {
332 332
 
333 333
   var conference = this;
334 334
   return new Promise(function (resolve, reject) {
335
-    conference.xmpp.lockRoom(password, function () {
335
+    conference.room.lockRoom(password || "", function () {
336 336
       resolve();
337 337
     }, function (err) {
338 338
       reject(err);
@@ -347,7 +347,7 @@ JitsiConference.prototype.lock = function (password) {
347 347
  * @returns {Promise}
348 348
  */
349 349
 JitsiConference.prototype.unlock = function () {
350
-  return this.lock(undefined);
350
+  return this.lock();
351 351
 };
352 352
 
353 353
 /**
@@ -10482,8 +10482,7 @@ module.exports = TraceablePeerConnection;
10482 10482
 }).call(this,"/modules/xmpp/TraceablePeerConnection.js")
10483 10483
 },{"../../service/xmpp/XMPPEvents":87,"../RTC/RTC":16,"../RTC/RTCBrowserType.js":17,"./LocalSSRCReplacement":29,"jitsi-meet-logger":48,"sdp-interop":66,"sdp-simulcast":69,"sdp-transform":76}],34:[function(require,module,exports){
10484 10484
 (function (__filename){
10485
-/* global $, $iq, APP, config, messageHandler,
10486
- roomName, sessionTerminated, Strophe, Util */
10485
+/* global $, $iq, Promise, Strophe */
10487 10486
 
10488 10487
 var logger = require("jitsi-meet-logger").getLogger(__filename);
10489 10488
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
@@ -10838,6 +10837,22 @@ Moderator.prototype.allocateConferenceFocus =  function (callback) {
10838 10837
     );
10839 10838
 };
10840 10839
 
10840
+Moderator.prototype.authenticate = function () {
10841
+    var self = this;
10842
+    return new Promise(function (resolve, reject) {
10843
+        self.connection.sendIQ(
10844
+            self.createConferenceIq(),
10845
+            function (result) {
10846
+                self.parseSessionId(result);
10847
+                resolve();
10848
+            }, function (error) {
10849
+                var code = $(error).find('>error').attr('code');
10850
+                reject(error, code);
10851
+            }
10852
+        );
10853
+    });
10854
+};
10855
+
10841 10856
 Moderator.prototype.getLoginUrl =  function (urlCallback, failureCallback) {
10842 10857
     var iq = $iq({to: this.getFocusComponent(), type: 'get'});
10843 10858
     iq.c('login-url', {

+ 21
- 8
modules/AuthHandler.js 查看文件

@@ -1,4 +1,4 @@
1
-/* global JitsiMeetJS */
1
+/* global JitsiMeetJS, APP */
2 2
 
3 3
 import LoginDialog from './UI/authentication/LoginDialog';
4 4
 import UIEvents from '../service/UI/UIEvents';
@@ -44,14 +44,16 @@ function doXmppAuth (room, lockPassword) {
44 44
             // open room
45 45
             let newRoom = connection.initJitsiConference(room.getName());
46 46
 
47
-            newRoom.on(ConferenceEvents.CONFERENCE_FAILED, function (err) {
48
-                connection.disconnect();
49
-                loginDialog.displayError(err);
50
-            });
47
+            loginDialog.displayConnectionStatus(
48
+                APP.translation.translateString('connection.FETCH_SESSION_ID')
49
+            );
51 50
 
52
-            newRoom.room.moderator.allocateConferenceFocus(function () {
51
+            newRoom.room.moderator.authenticate().then(function () {
53 52
                 connection.disconnect();
54
-                loginDialog.close();
53
+
54
+                loginDialog.displayConnectionStatus(
55
+                    APP.translation.translateString('connection.GOT_SESSION_ID')
56
+                );
55 57
 
56 58
                 if (room.isJoined()) {
57 59
                     // just reallocate focus if already joined
@@ -60,8 +62,19 @@ function doXmppAuth (room, lockPassword) {
60 62
                     // or join
61 63
                     room.join(lockPassword);
62 64
                 }
63
-            });
64 65
 
66
+                loginDialog.close();
67
+            }).catch(function (error, code) {
68
+                connection.disconnect();
69
+
70
+                console.error('Auth on the fly failed', error);
71
+
72
+                let errorMsg = APP.translation.translateString(
73
+                    'connection.GET_SESSION_ID_ERROR'
74
+                );
75
+
76
+                loginDialog.displayError(errorMsg + code);
77
+            });
65 78
         }, function (err) {
66 79
             loginDialog.displayError(err);
67 80
         });

+ 2
- 1
modules/RoomLocker.js 查看文件

@@ -92,6 +92,7 @@ export default function createRoomLocker (room) {
92 92
         return room.lock(newPass).then(function () {
93 93
             password = newPass;
94 94
         }).catch(function (err) {
95
+            console.error(err);
95 96
             if (err === ConferenceErrors.PASSWORD_NOT_SUPPORTED) {
96 97
                 notifyPasswordNotSupported();
97 98
             } else {
@@ -111,7 +112,7 @@ export default function createRoomLocker (room) {
111 112
         },
112 113
 
113 114
         askToUnlock () {
114
-            askToUnlock().then(function () {
115
+            return askToUnlock().then(function () {
115 116
                 return lock();
116 117
             }).then(function () {
117 118
                 AnalyticsAdapter.sendEvent('toolbar.lock.disabled');

+ 9
- 2
modules/UI/authentication/LoginDialog.js 查看文件

@@ -110,14 +110,21 @@ function Dialog(successCallback, cancelCallback) {
110 110
      */
111 111
     this.displayError = function (message) {
112 112
 
113
-        var finishedState = connDialog.getState('finished');
113
+        let finishedState = connDialog.getState('finished');
114 114
 
115
-        var errorMessageElem = finishedState.find('#errorMessage');
115
+        let errorMessageElem = finishedState.find('#errorMessage');
116 116
         errorMessageElem.text(message);
117 117
 
118 118
         connDialog.goToState('finished');
119 119
     };
120 120
 
121
+    this.displayConnectionStatus = function (message) {
122
+        let connectingState = connDialog.getState('connecting');
123
+
124
+        let connectionStatus = connectingState.find('#connectionStatus');
125
+        connectionStatus.text(message);
126
+    };
127
+
121 128
     /**
122 129
      * Closes LoginDialog.
123 130
      */

正在加载...
取消
保存