Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
implement user logout
isymchych3cf478826eb3
diff --git a/conference.js b/conference.jsindex 44e9ddefc9..201174586f 100644--- a/conference.js+++ b/conference.js@@ -110,6 +110,33 @@ function muteLocalVideo (muted) {}}+/**+ * Disconnect from the conference and optionally request user feedback.+ * @param {boolean} [requestFeedback=false] if user feedback should be requested+ */+function hangup (requestFeedback = false) {+ let promise = Promise.resolve();++ if (requestFeedback) {+ promise = APP.UI.requestFeedback();+ }++ promise.then(function () {+ connection.disconnect();++ if (!config.enableWelcomePage) {+ return;+ }+ // redirect to welcome page+ setTimeout(() => {+ APP.settings.setWelcomePageEnabled(true);+ window.location.pathname = "/";+ }, 3000);+ }, function (err) {+ console.error('Failed to hangup the call:', err);+ });+}+/*** Create local tracks of specified types.* @param {string[]} devices required track types ('audio', 'video' etc.)@@ -915,25 +942,18 @@ export default {// call hangupAPP.UI.addListener(UIEvents.HANGUP, () => {- APP.UI.requestFeedback().then(() => {- connection.disconnect();- config.enableWelcomePage && setTimeout(() => {- window.localStorage.welcomePageDisabled = false;- window.location.pathname = "/";- }, 3000);- }, (err) => {console.error(err);});+ hangup(true);});// logoutAPP.UI.addListener(UIEvents.LOGOUT, () => {- // FIXME handle logout- // APP.xmpp.logout(function (url) {- // if (url) {- // window.location.href = url;- // } else {- // hangup();- // }- // });+ AuthHandler.logout(room).then(function (url) {+ if (url) {+ window.location.href = url;+ } else {+ hangup(true);+ }+ });});APP.UI.addListener(UIEvents.SIP_DIAL, (sipNumber) => {diff --git a/modules/UI/UI.js b/modules/UI/UI.jsindex c75c7b926c..ff803bf02c 100644--- a/modules/UI/UI.js+++ b/modules/UI/UI.js@@ -315,8 +315,7 @@ UI.start = function () {document.title = interfaceConfig.APP_NAME;var setupWelcomePage = null;if(config.enableWelcomePage && window.location.pathname == "/" &&- (!window.localStorage.welcomePageDisabled ||- window.localStorage.welcomePageDisabled == "false")) {+ Settings.isWelcomePageEnabled()) {$("#videoconference_page").hide();if (!setupWelcomePage)setupWelcomePage = require("./welcome_page/WelcomePage");diff --git a/modules/UI/authentication/AuthHandler.js b/modules/UI/authentication/AuthHandler.jsindex 6de5e26150..5efc504140 100644--- a/modules/UI/authentication/AuthHandler.js+++ b/modules/UI/authentication/AuthHandler.js@@ -69,6 +69,7 @@ function doXmppAuth (room, lockPassword) {APP.translation.translateString('connection.GOT_SESSION_ID'));+ // authenticate conference on the flyroom.join(lockPassword);loginDialog.close();@@ -105,6 +106,26 @@ function authenticate (room, lockPassword) {}}+/**+ * De-authenticate local user.+ *+ * @param {JitsiConference} room+ * @param {string} [lockPassword] password to use if the conference is locked+ * @returns {Promise}+ */+function logout (room) {+ return new Promise(function (resolve) {+ room.room.moderator.logout(resolve);+ }).then(function (url) {+ // de-authenticate conference on the fly+ if (room.isJoined()) {+ room.join();+ }++ return url;+ });+}+/*** Notify user that authentication is required to create the conference.* @param {JitsiConference} room@@ -139,5 +160,6 @@ function closeAuth() {export default {authenticate,requireAuth,- closeAuth+ closeAuth,+ logout};diff --git a/modules/UI/welcome_page/WelcomePage.js b/modules/UI/welcome_page/WelcomePage.jsindex 8d2a05d154..81435baa75 100644--- a/modules/UI/welcome_page/WelcomePage.js+++ b/modules/UI/welcome_page/WelcomePage.js@@ -1,4 +1,4 @@-/* global $, interfaceConfig */+/* global $, interfaceConfig, APP */var animateTimeout, updateTimeout;var RoomnameGenerator = require("../../util/RoomnameGenerator");@@ -87,10 +87,11 @@ function setupWelcomePage() {}$("#disable_welcome").click(function () {- window.localStorage.welcomePageDisabled =- $("#disable_welcome").is(":checked");+ APP.settings.setWelcomePageEnabled(+ !$("#disable_welcome").is(":checked")+ );});}-module.exports = setupWelcomePage;\ No newline at end of file+module.exports = setupWelcomePage;diff --git a/modules/settings/Settings.js b/modules/settings/Settings.jsindex 7ffe4a667d..3b4deb3690 100644--- a/modules/settings/Settings.js+++ b/modules/settings/Settings.js@@ -7,6 +7,7 @@ let userId;let language = null;let cameraDeviceId = '';let micDeviceId = '';+let welcomePageDisabled = false;function supportsLocalStorage() {try {@@ -37,6 +38,9 @@ if (supportsLocalStorage()) {language = window.localStorage.language;cameraDeviceId = window.localStorage.cameraDeviceId || '';micDeviceId = window.localStorage.micDeviceId || '';+ welcomePageDisabled = JSON.parse(+ window.localStorage.welcomePageDisabled || false+ );} else {console.log("local storage is not supported");userId = generateUniqueId();@@ -130,5 +134,22 @@ export default {setMicDeviceId: function (newId = '') {micDeviceId = newId;window.localStorage.micDeviceId = newId;+ },++ /**+ * Check if welcome page is enabled or not.+ * @returns {boolean}+ */+ isWelcomePageEnabled () {+ return !welcomePageDisabled;+ },++ /**+ * Enable or disable welcome page.+ * @param {boolean} enabled if welcome page should be enabled or not+ */+ setWelcomePageEnabled (enabled) {+ welcomePageDisabled = !enabled;+ window.localStorage.welcomePageDisabled = welcomePageDisabled;}};