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
Move XMPP login prompt handling to AuthHandler
paweldomas38fc1c01d4c5
diff --git a/connection.js b/connection.jsindex 5add17e483..94f73e5e42 100644--- a/connection.js+++ b/connection.js@@ -1,6 +1,5 @@/* global APP, JitsiMeetJS, config */-//FIXME:-import LoginDialog from './modules/UI/authentication/LoginDialog';+import AuthHandler from './modules/UI/authentication/AuthHandler';const ConnectionEvents = JitsiMeetJS.events.connection;const ConnectionErrors = JitsiMeetJS.errors.connection;@@ -92,33 +91,6 @@ function connect(id, password, roomName) {});}-/**- * Show Authentication Dialog and try to connect with new credentials.- * If failed to connect because of PASSWORD_REQUIRED error- * then ask for password again.- * @param {string} [roomName]- * @returns {Promise<JitsiConnection>}- */-function requestAuth(roomName) {- return new Promise(function (resolve, reject) {- let authDialog = LoginDialog.showAuthDialog(- function (id, password) {- connect(id, password, roomName).then(function (connection) {- authDialog.close();- resolve(connection);- }, function (err) {- if (err === ConnectionErrors.PASSWORD_REQUIRED) {- authDialog.displayError(err);- } else {- authDialog.close();- reject(err);- }- });- }- );- });-}-/*** Open JitsiConnection using provided credentials.* If retry option is true it will show auth dialog on PASSWORD_REQUIRED error.@@ -157,7 +129,7 @@ export function openConnection({id, password, retry, roomName}) {if (config.token) {throw err;} else {- return requestAuth(roomName);+ return AuthHandler.requestAuth(roomName, connect);}} else {throw err;diff --git a/modules/UI/authentication/AuthHandler.js b/modules/UI/authentication/AuthHandler.jsindex fc321af3a2..98586d13c6 100644--- a/modules/UI/authentication/AuthHandler.js+++ b/modules/UI/authentication/AuthHandler.js@@ -1,11 +1,11 @@-/* global JitsiMeetJS, APP */+/* global APP, config, JitsiMeetJS, Promise */import LoginDialog from './LoginDialog';-import UIEvents from '../../../service/UI/UIEvents';import UIUtil from '../util/UIUtil';import {openConnection} from '../../../connection';const ConferenceEvents = JitsiMeetJS.events.conference;+const ConnectionErrors = JitsiMeetJS.errors.connection;let externalAuthWindow;let authRequiredDialog;@@ -157,10 +157,45 @@ function closeAuth() {}}+function showXmppPasswordPrompt(roomName, connect) {+ return new Promise(function (resolve, reject) {+ let authDialog = LoginDialog.showAuthDialog(+ function (id, password) {+ connect(id, password, roomName).then(function (connection) {+ authDialog.close();+ resolve(connection);+ }, function (err) {+ if (err === ConnectionErrors.PASSWORD_REQUIRED) {+ authDialog.displayError(err);+ } else {+ authDialog.close();+ reject(err);+ }+ });+ }+ );+ });+}++/**+ * Show Authentication Dialog and try to connect with new credentials.+ * If failed to connect because of PASSWORD_REQUIRED error+ * then ask for password again.+ * @param {string} [roomName] name of the conference room+ * @param {function(id, password, roomName)} [connect] function that returns+ * a Promise which resolves with JitsiConnection or fails with one of+ * ConnectionErrors.+ * @returns {Promise<JitsiConnection>}+ */+function requestAuth(roomName, connect) {+ return showXmppPasswordPrompt(roomName, connect);+}+export default {authenticate,requireAuth,+ requestAuth,closeAuth,logout};