Bläddra i källkod

implement user logout

j8
isymchych 9 år sedan
förälder
incheckning
3cf478826e

+ 35
- 15
conference.js Visa fil

110
     }
110
     }
111
 }
111
 }
112
 
112
 
113
+/**
114
+ * Disconnect from the conference and optionally request user feedback.
115
+ * @param {boolean} [requestFeedback=false] if user feedback should be requested
116
+ */
117
+function hangup (requestFeedback = false) {
118
+    let promise = Promise.resolve();
119
+
120
+    if (requestFeedback) {
121
+        promise = APP.UI.requestFeedback();
122
+    }
123
+
124
+    promise.then(function () {
125
+        connection.disconnect();
126
+
127
+        if (!config.enableWelcomePage) {
128
+            return;
129
+        }
130
+        // redirect to welcome page
131
+        setTimeout(() => {
132
+            APP.settings.setWelcomePageEnabled(true);
133
+            window.location.pathname = "/";
134
+        }, 3000);
135
+    }, function (err) {
136
+        console.error('Failed to hangup the call:', err);
137
+    });
138
+}
139
+
113
 /**
140
 /**
114
  * Create local tracks of specified types.
141
  * Create local tracks of specified types.
115
  * @param {string[]} devices required track types ('audio', 'video' etc.)
142
  * @param {string[]} devices required track types ('audio', 'video' etc.)
915
 
942
 
916
         // call hangup
943
         // call hangup
917
         APP.UI.addListener(UIEvents.HANGUP, () => {
944
         APP.UI.addListener(UIEvents.HANGUP, () => {
918
-            APP.UI.requestFeedback().then(() => {
919
-                connection.disconnect();
920
-                config.enableWelcomePage && setTimeout(() => {
921
-                        window.localStorage.welcomePageDisabled = false;
922
-                        window.location.pathname = "/";
923
-                    }, 3000);
924
-            }, (err) => {console.error(err);});
945
+            hangup(true);
925
         });
946
         });
926
 
947
 
927
         // logout
948
         // logout
928
         APP.UI.addListener(UIEvents.LOGOUT, () => {
949
         APP.UI.addListener(UIEvents.LOGOUT, () => {
929
-            // FIXME handle logout
930
-            // APP.xmpp.logout(function (url) {
931
-            //     if (url) {
932
-            //         window.location.href = url;
933
-            //     } else {
934
-            //         hangup();
935
-            //     }
936
-            // });
950
+            AuthHandler.logout(room).then(function (url) {
951
+                if (url) {
952
+                    window.location.href = url;
953
+                } else {
954
+                    hangup(true);
955
+                }
956
+            });
937
         });
957
         });
938
 
958
 
939
         APP.UI.addListener(UIEvents.SIP_DIAL, (sipNumber) => {
959
         APP.UI.addListener(UIEvents.SIP_DIAL, (sipNumber) => {

+ 1
- 2
modules/UI/UI.js Visa fil

315
     document.title = interfaceConfig.APP_NAME;
315
     document.title = interfaceConfig.APP_NAME;
316
     var setupWelcomePage = null;
316
     var setupWelcomePage = null;
317
     if(config.enableWelcomePage && window.location.pathname == "/" &&
317
     if(config.enableWelcomePage && window.location.pathname == "/" &&
318
-        (!window.localStorage.welcomePageDisabled ||
319
-            window.localStorage.welcomePageDisabled == "false")) {
318
+       Settings.isWelcomePageEnabled()) {
320
         $("#videoconference_page").hide();
319
         $("#videoconference_page").hide();
321
         if (!setupWelcomePage)
320
         if (!setupWelcomePage)
322
             setupWelcomePage = require("./welcome_page/WelcomePage");
321
             setupWelcomePage = require("./welcome_page/WelcomePage");

+ 23
- 1
modules/UI/authentication/AuthHandler.js Visa fil

69
                     APP.translation.translateString('connection.GOT_SESSION_ID')
69
                     APP.translation.translateString('connection.GOT_SESSION_ID')
70
                 );
70
                 );
71
 
71
 
72
+                // authenticate conference on the fly
72
                 room.join(lockPassword);
73
                 room.join(lockPassword);
73
 
74
 
74
                 loginDialog.close();
75
                 loginDialog.close();
105
     }
106
     }
106
 }
107
 }
107
 
108
 
109
+/**
110
+ * De-authenticate local user.
111
+ *
112
+ * @param {JitsiConference} room
113
+ * @param {string} [lockPassword] password to use if the conference is locked
114
+ * @returns {Promise}
115
+ */
116
+function logout (room) {
117
+    return new Promise(function (resolve) {
118
+        room.room.moderator.logout(resolve);
119
+    }).then(function (url) {
120
+        // de-authenticate conference on the fly
121
+        if (room.isJoined()) {
122
+            room.join();
123
+        }
124
+
125
+        return url;
126
+    });
127
+}
128
+
108
 /**
129
 /**
109
  * Notify user that authentication is required to create the conference.
130
  * Notify user that authentication is required to create the conference.
110
  * @param {JitsiConference} room
131
  * @param {JitsiConference} room
139
 export default {
160
 export default {
140
     authenticate,
161
     authenticate,
141
     requireAuth,
162
     requireAuth,
142
-    closeAuth
163
+    closeAuth,
164
+    logout
143
 };
165
 };

+ 5
- 4
modules/UI/welcome_page/WelcomePage.js Visa fil

1
-/* global $, interfaceConfig */
1
+/* global $, interfaceConfig, APP */
2
 var animateTimeout, updateTimeout;
2
 var animateTimeout, updateTimeout;
3
 
3
 
4
 var RoomnameGenerator = require("../../util/RoomnameGenerator");
4
 var RoomnameGenerator = require("../../util/RoomnameGenerator");
87
     }
87
     }
88
 
88
 
89
     $("#disable_welcome").click(function () {
89
     $("#disable_welcome").click(function () {
90
-        window.localStorage.welcomePageDisabled =
91
-            $("#disable_welcome").is(":checked");
90
+        APP.settings.setWelcomePageEnabled(
91
+            !$("#disable_welcome").is(":checked")
92
+        );
92
     });
93
     });
93
 
94
 
94
 }
95
 }
95
 
96
 
96
-module.exports = setupWelcomePage;
97
+module.exports = setupWelcomePage;

+ 21
- 0
modules/settings/Settings.js Visa fil

7
 let language = null;
7
 let language = null;
8
 let cameraDeviceId = '';
8
 let cameraDeviceId = '';
9
 let micDeviceId = '';
9
 let micDeviceId = '';
10
+let welcomePageDisabled = false;
10
 
11
 
11
 function supportsLocalStorage() {
12
 function supportsLocalStorage() {
12
     try {
13
     try {
37
     language = window.localStorage.language;
38
     language = window.localStorage.language;
38
     cameraDeviceId = window.localStorage.cameraDeviceId || '';
39
     cameraDeviceId = window.localStorage.cameraDeviceId || '';
39
     micDeviceId = window.localStorage.micDeviceId || '';
40
     micDeviceId = window.localStorage.micDeviceId || '';
41
+    welcomePageDisabled = JSON.parse(
42
+        window.localStorage.welcomePageDisabled || false
43
+    );
40
 } else {
44
 } else {
41
     console.log("local storage is not supported");
45
     console.log("local storage is not supported");
42
     userId = generateUniqueId();
46
     userId = generateUniqueId();
130
     setMicDeviceId: function (newId = '') {
134
     setMicDeviceId: function (newId = '') {
131
         micDeviceId = newId;
135
         micDeviceId = newId;
132
         window.localStorage.micDeviceId = newId;
136
         window.localStorage.micDeviceId = newId;
137
+    },
138
+
139
+    /**
140
+     * Check if welcome page is enabled or not.
141
+     * @returns {boolean}
142
+     */
143
+    isWelcomePageEnabled () {
144
+        return !welcomePageDisabled;
145
+    },
146
+
147
+    /**
148
+     * Enable or disable welcome page.
149
+     * @param {boolean} enabled if welcome page should be enabled or not
150
+     */
151
+    setWelcomePageEnabled (enabled) {
152
+        welcomePageDisabled = !enabled;
153
+        window.localStorage.welcomePageDisabled = welcomePageDisabled;
133
     }
154
     }
134
 };
155
 };

Laddar…
Avbryt
Spara