Move XMPP login prompt handling to AuthHandler
This commit is contained in:
parent
ce5ff20d5b
commit
38fc1c01d4
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue