implement user logout
This commit is contained in:
parent
b73bddf1c4
commit
3cf478826e
|
@ -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 hangup
|
||||
APP.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);
|
||||
});
|
||||
|
||||
// logout
|
||||
APP.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) => {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -69,6 +69,7 @@ function doXmppAuth (room, lockPassword) {
|
|||
APP.translation.translateString('connection.GOT_SESSION_ID')
|
||||
);
|
||||
|
||||
// authenticate conference on the fly
|
||||
room.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
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
module.exports = setupWelcomePage;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue