Browse Source

Adds auto-sign in feature and login/logout toolbar menu.

master
paweldomas 10 years ago
parent
commit
a904e35c67

+ 61
- 0
css/login_menu.css View File

1
+/*Initialize*/
2
+ul.loginmenu {
3
+    display:none;
4
+    position: absolute;
5
+    margin: 0;
6
+    padding: 5px;
7
+    padding-bottom: 7px;
8
+    top: 45px;
9
+    left: -5px;
10
+    background-color: rgba(0,0,0,0.9);
11
+    border: 1px solid rgba(256, 256, 256, 0.2);
12
+    border-radius:8px;
13
+}
14
+
15
+ul.loginmenu li {
16
+    list-style-type: none;
17
+    padding: 7px;
18
+}
19
+
20
+ul.loginmenu li.identity {
21
+    color: #fff;
22
+    font-size: 11pt;
23
+    cursor: default;
24
+}
25
+
26
+ul.loginmenu:after {
27
+    content: url('../images/dropdownPointer.png');
28
+    display: block;
29
+    position: absolute;
30
+    top: -7px;
31
+    left: 18px;
32
+}
33
+
34
+li a.authButton{
35
+    background-color: #06a5df;
36
+    padding-top: 3px;
37
+    padding-bottom: 3px;
38
+    padding-left: 29px;
39
+    padding-right: 29px;
40
+    border-radius: 4px;
41
+    color: #fff;
42
+    font-size: 11pt;
43
+    cursor: pointer;
44
+}
45
+
46
+span.authentication:hover ul.loginmenu, ul.loginmenu:hover {
47
+    display:block !important;
48
+}
49
+
50
+a.disabled {
51
+    color: gray !important;
52
+    pointer-events: none;
53
+}
54
+
55
+.loginmenuPadding {
56
+    width: 50px;
57
+    height: 30px;
58
+    position: absolute;
59
+    top: -30px;
60
+    left: 0px;
61
+}

BIN
images/dropdownPointer.png View File


+ 17
- 6
index.html View File

30
     <link rel="stylesheet" href="css/jquery-impromptu.css?v=4">
30
     <link rel="stylesheet" href="css/jquery-impromptu.css?v=4">
31
     <link rel="stylesheet" href="css/modaldialog.css?v=3">
31
     <link rel="stylesheet" href="css/modaldialog.css?v=3">
32
     <link rel="stylesheet" href="css/popup_menu.css?v=4">
32
     <link rel="stylesheet" href="css/popup_menu.css?v=4">
33
+    <link rel="stylesheet" href="css/login_menu.css?v=1">
33
     <link rel="stylesheet" href="css/popover.css?v=2">
34
     <link rel="stylesheet" href="css/popover.css?v=2">
34
     <link rel="stylesheet" href="css/jitsi_popover.css?v=2">
35
     <link rel="stylesheet" href="css/jitsi_popover.css?v=2">
35
     <link rel="stylesheet" href="css/contact_list.css?v=4">
36
     <link rel="stylesheet" href="css/contact_list.css?v=4">
121
         <div style="position: relative;" id="header_container">
122
         <div style="position: relative;" id="header_container">
122
             <div id="header">
123
             <div id="header">
123
                 <span id="toolbar">
124
                 <span id="toolbar">
125
+                    <span id="authentication" class="authentication" style="display: none">
126
+                        <a class="button" id="toolbar_button_authentication" >
127
+                            <i id="authButton" class="icon-avatar"></i>
128
+                        </a>
129
+                        <ul class="loginmenu">
130
+                            <span class="loginmenuPadding"></span>
131
+                            <li id="toolbar_auth_identity" class="identity"></li>
132
+                            <li id="toolbar_button_login">
133
+                                <a class="authButton" data-i18n="toolbar.login"></a>
134
+                            </li>
135
+                            <li id="toolbar_button_logout">
136
+                                <a class="authButton" data-i18n="toolbar.logout"></a>
137
+                            </li>
138
+                        </ul>
139
+                        <div class="header_button_separator"></div>
140
+                    </span>
124
                     <a class="button" id="toolbar_button_mute" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="mutePopover" data-i18n="[content]toolbar.mute" content="Mute / Unmute">
141
                     <a class="button" id="toolbar_button_mute" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="mutePopover" data-i18n="[content]toolbar.mute" content="Mute / Unmute">
125
                         <i id="mute" class="icon-microphone"></i>
142
                         <i id="mute" class="icon-microphone"></i>
126
                     </a>
143
                     </a>
128
                     <a class="button" id="toolbar_button_camera" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleVideoPopover" data-i18n="[content]toolbar.videomute" content="Start / stop camera">
145
                     <a class="button" id="toolbar_button_camera" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleVideoPopover" data-i18n="[content]toolbar.videomute" content="Start / stop camera">
129
                         <i id="video" class="icon-camera"></i>
146
                         <i id="video" class="icon-camera"></i>
130
                     </a>
147
                     </a>
131
-                    <span id="authentication" style="display: none">
132
-                        <div class="header_button_separator"></div>
133
-                        <a class="button" id="toolbar_button_authentication" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.authenticate" content="Authenticate">
134
-                            <i id="authButton" class="icon-avatar"></i>
135
-                        </a>
136
-                    </span>
137
                     <span id="recording" style="display: none">
148
                     <span id="recording" style="display: none">
138
                         <div class="header_button_separator"></div>
149
                         <div class="header_button_separator"></div>
139
                         <a class="button" id="toolbar_button_record" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.record" content="Record">
150
                         <a class="button" id="toolbar_button_record" data-container="body" data-toggle="popover" data-placement="bottom" data-i18n="[content]toolbar.record" content="Record">

+ 3
- 1
lang/main.json View File

54
         "fullscreen": "Enter / Exit Full Screen",
54
         "fullscreen": "Enter / Exit Full Screen",
55
         "sip": "Call SIP number",
55
         "sip": "Call SIP number",
56
         "Settings": "Settings",
56
         "Settings": "Settings",
57
-        "hangup": "Hang Up"
57
+        "hangup": "Hang Up",
58
+        "login": "Login",
59
+        "logout": "Logout"
58
     },
60
     },
59
     "bottomtoolbar": {
61
     "bottomtoolbar": {
60
         "chat": "Open / close chat",
62
         "chat": "Open / close chat",

+ 17969
- 17734
libs/app.bundle.js
File diff suppressed because it is too large
View File


+ 1
- 7
modules/UI/UI.js View File

371
     // Once we've joined the muc show the toolbar
371
     // Once we've joined the muc show the toolbar
372
     ToolbarToggler.showToolbar();
372
     ToolbarToggler.showToolbar();
373
 
373
 
374
-    // Show authenticate button if needed
375
-    Toolbar.showAuthenticateButton(
376
-            APP.xmpp.isExternalAuthEnabled() && !APP.xmpp.isModerator());
377
-
378
     var displayName = !config.displayJids
374
     var displayName = !config.displayJids
379
         ? info.displayName : Strophe.getResourceFromJid(jid);
375
         ? info.displayName : Strophe.getResourceFromJid(jid);
380
 
376
 
413
 };
409
 };
414
 
410
 
415
 
411
 
416
-function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
412
+function onLocalRoleChange(jid, info, pres, isModerator)
417
 {
413
 {
418
 
414
 
419
     console.info("My role changed, new role: " + info.role);
415
     console.info("My role changed, new role: " + info.role);
420
     onModeratorStatusChanged(isModerator);
416
     onModeratorStatusChanged(isModerator);
421
     VideoLayout.showModeratorIndicator();
417
     VideoLayout.showModeratorIndicator();
422
-    Toolbar.showAuthenticateButton(
423
-            isExternalAuthEnabled && !isModerator);
424
 
418
 
425
     if (isModerator) {
419
     if (isModerator) {
426
         Authentication.closeAuthenticationWindow();
420
         Authentication.closeAuthenticationWindow();

+ 2
- 2
modules/UI/authentication/Authentication.js View File

16
         // extract room name from 'room@muc.server.net'
16
         // extract room name from 'room@muc.server.net'
17
         var room = roomName.substr(0, roomName.indexOf('@'));
17
         var room = roomName.substr(0, roomName.indexOf('@'));
18
 
18
 
19
-        authDialog = messageHandler.openDialog(
19
+        authDialog = APP.UI.messageHandler.openDialog(
20
             'Stop',
20
             'Stop',
21
                 'Authentication is required to create room:<br/><b>' + room +
21
                 'Authentication is required to create room:<br/><b>' + room +
22
                 '</b></br> You can either authenticate to create the room or ' +
22
                 '</b></br> You can either authenticate to create the room or ' +
58
         }
58
         }
59
     },
59
     },
60
     createAuthenticationWindow: function (callback, url) {
60
     createAuthenticationWindow: function (callback, url) {
61
-        authenticationWindow = messageHandler.openCenteredPopup(
61
+        authenticationWindow = APP.UI.messageHandler.openCenteredPopup(
62
             url, 910, 660,
62
             url, 910, 660,
63
             // On closed
63
             // On closed
64
             function () {
64
             function () {

+ 113
- 17
modules/UI/toolbars/Toolbar.js View File

1
-/* global $, buttonClick, config, lockRoom,
1
+/* global APP,$, buttonClick, config, lockRoom,
2
    setSharedKey, Util */
2
    setSharedKey, Util */
3
 var messageHandler = require("../util/MessageHandler");
3
 var messageHandler = require("../util/MessageHandler");
4
 var BottomToolbar = require("./BottomToolbar");
4
 var BottomToolbar = require("./BottomToolbar");
7
 var PanelToggler = require("../side_pannels/SidePanelToggler");
7
 var PanelToggler = require("../side_pannels/SidePanelToggler");
8
 var Authentication = require("../authentication/Authentication");
8
 var Authentication = require("../authentication/Authentication");
9
 var UIUtil = require("../util/UIUtil");
9
 var UIUtil = require("../util/UIUtil");
10
+var AuthenticationEvents
11
+    = require("../../../service/authentication/AuthenticationEvents");
10
 
12
 
11
 var roomUrl = null;
13
 var roomUrl = null;
12
 var sharedKey = '';
14
 var sharedKey = '';
20
     "toolbar_button_camera": function () {
22
     "toolbar_button_camera": function () {
21
         return APP.UI.toggleVideo();
23
         return APP.UI.toggleVideo();
22
     },
24
     },
23
-    "toolbar_button_authentication": function () {
25
+    /*"toolbar_button_authentication": function () {
24
         return Toolbar.authenticateClicked();
26
         return Toolbar.authenticateClicked();
25
-    },
27
+    },*/
26
     "toolbar_button_record": function () {
28
     "toolbar_button_record": function () {
27
         return toggleRecording();
29
         return toggleRecording();
28
     },
30
     },
57
     },
59
     },
58
     "toolbar_button_hangup": function () {
60
     "toolbar_button_hangup": function () {
59
         return hangup();
61
         return hangup();
62
+    },
63
+    "toolbar_button_login": function () {
64
+        Toolbar.authenticateClicked();
65
+    },
66
+    "toolbar_button_logout": function () {
67
+        // Ask for confirmation
68
+        messageHandler.openTwoButtonDialog(
69
+            "Logout",
70
+            "Are you sure you want to logout and stop the conference ?",
71
+            false, "Yes",
72
+            function (evt, yes) {
73
+                if (yes) {
74
+                    APP.xmpp.logout(function (url) {
75
+                        if (url) {
76
+                            window.location.href = url;
77
+                        } else {
78
+                            hangup();
79
+                        }
80
+                    });
81
+                }
82
+            });
60
     }
83
     }
61
 };
84
 };
62
 
85
 
222
         for(var k in buttonHandlers)
245
         for(var k in buttonHandlers)
223
             $("#" + k).click(buttonHandlers[k]);
246
             $("#" + k).click(buttonHandlers[k]);
224
         UI = ui;
247
         UI = ui;
225
-    }
248
+        // Update login info
249
+        APP.xmpp.addListener(
250
+            AuthenticationEvents.IDENTITY_UPDATED,
251
+            function (authenticationEnabled, userIdentity) {
252
+
253
+                var loggedIn = false;
254
+                if (userIdentity) {
255
+                    loggedIn = true;
256
+                }
257
+
258
+                //FIXME: XMPP authentication need improvements for "live" login
259
+                if (!APP.xmpp.isExternalAuthEnabled() && !loggedIn)
260
+                {
261
+                    authenticationEnabled = false;
262
+                }
263
+
264
+                Toolbar.showAuthenticateButton(authenticationEnabled);
265
+
266
+                if (authenticationEnabled) {
267
+                    Toolbar.setAuthenticatedIdentity(userIdentity);
268
+
269
+                    Toolbar.showLoginButton(!loggedIn);
270
+                    Toolbar.showLogoutButton(loggedIn);
271
+                }
272
+            }
273
+        );
274
+    },
226
 
275
 
227
     /**
276
     /**
228
      * Sets shared key
277
      * Sets shared key
235
     my.authenticateClicked = function () {
284
     my.authenticateClicked = function () {
236
         Authentication.focusAuthenticationWindow();
285
         Authentication.focusAuthenticationWindow();
237
         // Get authentication URL
286
         // Get authentication URL
238
-        APP.xmpp.getAuthUrl(APP.UI.getRoomName(), function (url) {
239
-            // Open popup with authentication URL
240
-            var authenticationWindow = Authentication.createAuthenticationWindow(function () {
241
-                // On popup closed - retry room allocation
242
-                APP.xmpp.allocateConferenceFocus(APP.UI.getRoomName(), APP.UI.checkForNicknameAndJoin);
243
-            }, url);
244
-            if (!authenticationWindow) {
245
-                Toolbar.showAuthenticateButton(true);
246
-                messageHandler.openMessageDialog(
247
-                    null, "Your browser is blocking popup windows from this site." +
287
+        if (!APP.xmpp.getMUCJoined()) {
288
+            APP.xmpp.getLoginUrl(UI.getRoomName(), function (url) {
289
+                // If conference has not been started yet - redirect to login page
290
+                window.location.href = url;
291
+            });
292
+        } else {
293
+            APP.xmpp.getPopupLoginUrl(UI.getRoomName(), function (url) {
294
+                // Otherwise - open popup with authentication URL
295
+                var authenticationWindow = Authentication.createAuthenticationWindow(
296
+                    function () {
297
+                        // On popup closed - retry room allocation
298
+                        APP.xmpp.allocateConferenceFocus(
299
+                            APP.UI.getRoomName(),
300
+                            function () { console.info("AUTH DONE"); }
301
+                        );
302
+                    }, url);
303
+                if (!authenticationWindow) {
304
+                    messageHandler.openMessageDialog(
305
+                        null, "Your browser is blocking popup windows from this site." +
248
                         " Please enable popups in your browser security settings" +
306
                         " Please enable popups in your browser security settings" +
249
                         " and try again.");
307
                         " and try again.");
250
-            }
251
-        });
308
+                }
309
+            });
310
+        }
252
     };
311
     };
253
 
312
 
254
     /**
313
     /**
489
     // Shows or hides SIP calls button
548
     // Shows or hides SIP calls button
490
     my.showSipCallButton = function (show) {
549
     my.showSipCallButton = function (show) {
491
         if (APP.xmpp.isSipGatewayEnabled() && show) {
550
         if (APP.xmpp.isSipGatewayEnabled() && show) {
492
-            $('#sipCallButton').css({display: "inline"});
551
+            $('#sipCallButton').css({display: "inline-block"});
493
         } else {
552
         } else {
494
             $('#sipCallButton').css({display: "none"});
553
             $('#sipCallButton').css({display: "none"});
495
         }
554
         }
496
     };
555
     };
497
 
556
 
557
+    /**
558
+     * Displays user authenticated identity name(login).
559
+     * @param authIdentity identity name to be displayed.
560
+     */
561
+    my.setAuthenticatedIdentity = function (authIdentity) {
562
+        if (authIdentity) {
563
+            $('#toolbar_auth_identity').css({display: "list-item"});
564
+            $('#toolbar_auth_identity').text(authIdentity);
565
+        } else {
566
+            $('#toolbar_auth_identity').css({display: "none"});
567
+        }
568
+    };
569
+
570
+    /**
571
+     * Shows/hides login button.
572
+     * @param show <tt>true</tt> to show
573
+     */
574
+    my.showLoginButton = function (show) {
575
+        if (show) {
576
+            $('#toolbar_button_login').css({display: "list-item"});
577
+        } else {
578
+            $('#toolbar_button_login').css({display: "none"});
579
+        }
580
+    };
581
+
582
+    /**
583
+     * Shows/hides logout button.
584
+     * @param show <tt>true</tt> to show
585
+     */
586
+    my.showLogoutButton = function (show) {
587
+        if (show) {
588
+            $('#toolbar_button_logout').css({display: "list-item"});
589
+        } else {
590
+            $('#toolbar_button_logout').css({display: "none"});
591
+        }
592
+    };
593
+
498
     /**
594
     /**
499
      * Sets the state of the button. The button has blue glow if desktop
595
      * Sets the state of the button. The button has blue glow if desktop
500
      * streaming is active.
596
      * streaming is active.

+ 141
- 18
modules/xmpp/moderator.js View File

1
 /* global $, $iq, config, connection, UI, messageHandler,
1
 /* global $, $iq, config, connection, UI, messageHandler,
2
  roomName, sessionTerminated, Strophe, Util */
2
  roomName, sessionTerminated, Strophe, Util */
3
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
3
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
4
+var Settings = require("../settings/Settings");
5
+
6
+var AuthenticationEvents
7
+    = require("../../service/authentication/AuthenticationEvents");
4
 
8
 
5
 /**
9
 /**
6
  * Contains logic responsible for enabling/disabling functionality available
10
  * Contains logic responsible for enabling/disabling functionality available
60
     init: function (xmpp, emitter) {
64
     init: function (xmpp, emitter) {
61
         this.xmppService = xmpp;
65
         this.xmppService = xmpp;
62
         eventEmitter = emitter;
66
         eventEmitter = emitter;
67
+
68
+        // Message listener that talks to POPUP window
69
+        function listener(event) {
70
+            if (event.data && event.data.sessionId) {
71
+                if (event.origin !== window.location.origin) {
72
+                    console.warn(
73
+                        "Ignoring sessionId from different origin: " + event.origin);
74
+                    return;
75
+                }
76
+                localStorage.setItem('sessionId', event.data.sessionId);
77
+                // After popup is closed we will authenticate
78
+            }
79
+        }
80
+        // Register
81
+        if (window.addEventListener) {
82
+            window.addEventListener("message", listener, false);
83
+        } else {
84
+            window.attachEvent("onmessage", listener);
85
+        }
63
     },
86
     },
64
 
87
 
65
     onMucLeft: function (jid) {
88
     onMucLeft: function (jid) {
99
     createConferenceIq: function (roomName) {
122
     createConferenceIq: function (roomName) {
100
         // Generate create conference IQ
123
         // Generate create conference IQ
101
         var elem = $iq({to: Moderator.getFocusComponent(), type: 'set'});
124
         var elem = $iq({to: Moderator.getFocusComponent(), type: 'set'});
125
+
126
+        // Session Id used for authentication
127
+        var sessionId = localStorage.getItem('sessionId');
128
+        var machineUID = Settings.getSettings().uid;
129
+
130
+        console.info(
131
+            "Session ID: " + sessionId + " machine UID: " + machineUID);
132
+
102
         elem.c('conference', {
133
         elem.c('conference', {
103
             xmlns: 'http://jitsi.org/protocol/focus',
134
             xmlns: 'http://jitsi.org/protocol/focus',
104
-            room: roomName
135
+            room: roomName,
136
+            'machine-uid': machineUID
105
         });
137
         });
138
+
139
+        if (sessionId) {
140
+            elem.attrs({ 'session-id': sessionId});
141
+        }
142
+
106
         if (config.hosts.bridge !== undefined) {
143
         if (config.hosts.bridge !== undefined) {
107
             elem.c(
144
             elem.c(
108
                 'property',
145
                 'property',
152
     },
189
     },
153
 
190
 
154
     parseConfigOptions: function (resultIq) {
191
     parseConfigOptions: function (resultIq) {
155
-    
192
+
156
         Moderator.setFocusUserJid(
193
         Moderator.setFocusUserJid(
157
             $(resultIq).find('conference').attr('focusjid'));
194
             $(resultIq).find('conference').attr('focusjid'));
158
-    
159
-        var extAuthParam
160
-            = $(resultIq).find('>conference>property[name=\'externalAuth\']');
161
-        if (extAuthParam.length) {
162
-            externalAuthEnabled = extAuthParam.attr('value') === 'true';
195
+
196
+        var authenticationEnabled
197
+            = $(resultIq).find(
198
+                '>conference>property' +
199
+                '[name=\'authentication\'][value=\'true\']').length > 0;
200
+
201
+        console.info("Authentication enabled: " + authenticationEnabled);
202
+
203
+        externalAuthEnabled
204
+            = $(resultIq).find(
205
+                '>conference>property' +
206
+                '[name=\'externalAuth\'][value=\'true\']').length > 0;
207
+
208
+        console.info('External authentication enabled: ' + externalAuthEnabled);
209
+
210
+        if (!externalAuthEnabled) {
211
+            // We expect to receive sessionId in 'internal' authentication mode
212
+            var sessionId
213
+                = $(resultIq).find('conference').attr('session-id');
214
+            if (sessionId) {
215
+                console.info('Received sessionId: ' + sessionId);
216
+                localStorage.setItem('sessionId', sessionId);
217
+            }
163
         }
218
         }
164
-    
165
-        console.info("External authentication enabled: " + externalAuthEnabled);
219
+
220
+        var authIdentity = $(resultIq).find('>conference').attr('identity');
221
+
222
+        eventEmitter.emit(AuthenticationEvents.IDENTITY_UPDATED,
223
+            authenticationEnabled, authIdentity);
166
     
224
     
167
         // Check if focus has auto-detected Jigasi component(this will be also
225
         // Check if focus has auto-detected Jigasi component(this will be also
168
         // included if we have passed our host from the config)
226
         // included if we have passed our host from the config)
169
         if ($(resultIq).find(
227
         if ($(resultIq).find(
170
-            '>conference>property[name=\'sipGatewayEnabled\']').length) {
228
+            '>conference>property' +
229
+            '[name=\'sipGatewayEnabled\'][value=\'true\']').length) {
171
             sipGatewayEnabled = true;
230
             sipGatewayEnabled = true;
172
         }
231
         }
173
     
232
     
185
         connection.sendIQ(
244
         connection.sendIQ(
186
             iq,
245
             iq,
187
             function (result) {
246
             function (result) {
247
+
248
+                // Setup config options
249
+                Moderator.parseConfigOptions(result);
250
+
188
                 if ('true' === $(result).find('conference').attr('ready')) {
251
                 if ('true' === $(result).find('conference').attr('ready')) {
189
                     // Reset both timers
252
                     // Reset both timers
190
                     getNextTimeout(true);
253
                     getNextTimeout(true);
191
                     getNextErrorTimeout(true);
254
                     getNextErrorTimeout(true);
192
-                    // Setup config options
193
-                    Moderator.parseConfigOptions(result);
194
                     // Exec callback
255
                     // Exec callback
195
                     callback();
256
                     callback();
196
                 } else {
257
                 } else {
208
             function (error) {
269
             function (error) {
209
                 // Not authorized to create new room
270
                 // Not authorized to create new room
210
                 if ($(error).find('>error>not-authorized').length) {
271
                 if ($(error).find('>error>not-authorized').length) {
211
-                    console.warn("Unauthorized to start the conference");
272
+                    console.warn("Unauthorized to start the conference", error);
273
+
274
+                    if ($(error).find('>error>session-invalid').length) {
275
+                        // FIXME: just retry
276
+                        console.info("Session expired! - removing");
277
+                        localStorage.removeItem("sessionId");
278
+                    }
279
+
212
                     var toDomain
280
                     var toDomain
213
                         = Strophe.getDomainFromJid(error.getAttribute('to'));
281
                         = Strophe.getDomainFromJid(error.getAttribute('to'));
214
                     if (toDomain === config.hosts.anonymousdomain) {
282
                     if (toDomain === config.hosts.anonymousdomain) {
248
         );
316
         );
249
     },
317
     },
250
 
318
 
251
-    getAuthUrl: function (roomName, urlCallback) {
319
+    getLoginUrl: function (roomName, urlCallback) {
252
         var iq = $iq({to: Moderator.getFocusComponent(), type: 'get'});
320
         var iq = $iq({to: Moderator.getFocusComponent(), type: 'get'});
253
-        iq.c('auth-url', {
321
+        iq.c('login-url', {
254
             xmlns: 'http://jitsi.org/protocol/focus',
322
             xmlns: 'http://jitsi.org/protocol/focus',
255
-            room: roomName
323
+            room: roomName,
324
+            'machine-uid': Settings.getSettings().uid
256
         });
325
         });
257
         connection.sendIQ(
326
         connection.sendIQ(
258
             iq,
327
             iq,
259
             function (result) {
328
             function (result) {
260
-                var url = $(result).find('auth-url').attr('url');
329
+                var url = $(result).find('login-url').attr('url');
330
+                url = url = decodeURIComponent(url);
261
                 if (url) {
331
                 if (url) {
262
                     console.info("Got auth url: " + url);
332
                     console.info("Got auth url: " + url);
263
                     urlCallback(url);
333
                     urlCallback(url);
264
                 } else {
334
                 } else {
265
                     console.error(
335
                     console.error(
266
-                        "Failed to get auth url fro mthe focus", result);
336
+                        "Failed to get auth url from the focus", result);
267
                 }
337
                 }
268
             },
338
             },
269
             function (error) {
339
             function (error) {
270
                 console.error("Get auth url error", error);
340
                 console.error("Get auth url error", error);
271
             }
341
             }
272
         );
342
         );
343
+    },
344
+    getPopupLoginUrl: function (roomName, urlCallback) {
345
+        var iq = $iq({to: Moderator.getFocusComponent(), type: 'get'});
346
+        iq.c('login-url', {
347
+            xmlns: 'http://jitsi.org/protocol/focus',
348
+            room: roomName,
349
+            'machine-uid': Settings.getSettings().uid,
350
+            popup: true
351
+        });
352
+        connection.sendIQ(
353
+            iq,
354
+            function (result) {
355
+                var url = $(result).find('login-url').attr('url');
356
+                url = url = decodeURIComponent(url);
357
+                if (url) {
358
+                    console.info("Got POPUP auth url: " + url);
359
+                    urlCallback(url);
360
+                } else {
361
+                    console.error(
362
+                        "Failed to get POPUP auth url from the focus", result);
363
+                }
364
+            },
365
+            function (error) {
366
+                console.error('Get POPUP auth url error', error);
367
+            }
368
+        );
369
+    },
370
+    logout: function (callback) {
371
+        var iq = $iq({to: Moderator.getFocusComponent(), type: 'set'});
372
+        var sessionId = localStorage.getItem('sessionId');
373
+        if (!sessionId) {
374
+            callback();
375
+            return;
376
+        }
377
+        iq.c('logout', {
378
+            xmlns: 'http://jitsi.org/protocol/focus',
379
+            'session-id': sessionId
380
+        });
381
+        connection.sendIQ(
382
+            iq,
383
+            function (result) {
384
+                var logoutUrl = $(result).find('logout').attr('logout-url');
385
+                if (logoutUrl) {
386
+                    logoutUrl = decodeURIComponent(logoutUrl);
387
+                }
388
+                console.info("Log out OK, url: " + logoutUrl, result);
389
+                localStorage.removeItem('sessionId');
390
+                callback(logoutUrl);
391
+            },
392
+            function (error) {
393
+                console.error("Logout error", error);
394
+            }
395
+        );
273
     }
396
     }
274
 };
397
 };
275
 
398
 

+ 1
- 2
modules/xmpp/strophe.emuc.js View File

183
                     this.role = member.role;
183
                     this.role = member.role;
184
 
184
 
185
                     eventEmitter.emit(XMPPEvents.LOCALROLE_CHANGED,
185
                     eventEmitter.emit(XMPPEvents.LOCALROLE_CHANGED,
186
-                        from, member, pres, Moderator.isModerator(),
187
-                        Moderator.isExternalAuthEnabled());
186
+                        from, member, pres, Moderator.isModerator());
188
                 }
187
                 }
189
                 if (!this.joined) {
188
                 if (!this.joined) {
190
                     this.joined = true;
189
                     this.joined = true;

+ 9
- 0
modules/xmpp/xmpp.js View File

230
     allocateConferenceFocus: function(roomName, callback) {
230
     allocateConferenceFocus: function(roomName, callback) {
231
         Moderator.allocateConferenceFocus(roomName, callback);
231
         Moderator.allocateConferenceFocus(roomName, callback);
232
     },
232
     },
233
+    getLoginUrl: function (roomName, callback) {
234
+        Moderator.getLoginUrl(roomName, callback);
235
+    },
236
+    getPopupLoginUrl: function (roomName, callback) {
237
+        Moderator.getPopupLoginUrl(roomName, callback);
238
+    },
233
     isModerator: function () {
239
     isModerator: function () {
234
         return Moderator.isModerator();
240
         return Moderator.isModerator();
235
     },
241
     },
421
     eject: function (jid) {
427
     eject: function (jid) {
422
         connection.moderate.eject(jid);
428
         connection.moderate.eject(jid);
423
     },
429
     },
430
+    logout: function (callback) {
431
+        Moderator.logout(callback);
432
+    },
424
     findJidFromResource: function (resource) {
433
     findJidFromResource: function (resource) {
425
         return connection.emuc.findJidFromResource(resource);
434
         return connection.emuc.findJidFromResource(resource);
426
     },
435
     },

+ 12
- 0
service/authentication/AuthenticationEvents.js View File

1
+var AuthenticationEvents = {
2
+    /**
3
+     * Event callback arguments:
4
+     * function(authenticationEnabled, userIdentity)
5
+     * authenticationEnabled - indicates whether authentication has been enabled
6
+     *                         in this session
7
+     * userIdentity - if user has been logged in then it contains user name. If
8
+     *                contains 'null' or 'undefined' then user is not logged in.
9
+     */
10
+    IDENTITY_UPDATED: "authentication.identity_updated"
11
+};
12
+module.exports = AuthenticationEvents;

Loading…
Cancel
Save