|
@@ -1,11 +1,11 @@
|
1
|
|
-/* global JitsiMeetJS, APP */
|
|
1
|
+/* global APP, config, JitsiMeetJS, Promise */
|
2
|
2
|
|
3
|
3
|
import LoginDialog from './LoginDialog';
|
4
|
|
-import UIEvents from '../../../service/UI/UIEvents';
|
5
|
4
|
import UIUtil from '../util/UIUtil';
|
6
|
5
|
import {openConnection} from '../../../connection';
|
7
|
6
|
|
8
|
7
|
const ConferenceEvents = JitsiMeetJS.events.conference;
|
|
8
|
+const ConnectionErrors = JitsiMeetJS.errors.connection;
|
9
|
9
|
|
10
|
10
|
let externalAuthWindow;
|
11
|
11
|
let authRequiredDialog;
|
|
@@ -157,10 +157,45 @@ function closeAuth() {
|
157
|
157
|
}
|
158
|
158
|
}
|
159
|
159
|
|
|
160
|
+function showXmppPasswordPrompt(roomName, connect) {
|
|
161
|
+ return new Promise(function (resolve, reject) {
|
|
162
|
+ let authDialog = LoginDialog.showAuthDialog(
|
|
163
|
+ function (id, password) {
|
|
164
|
+ connect(id, password, roomName).then(function (connection) {
|
|
165
|
+ authDialog.close();
|
|
166
|
+ resolve(connection);
|
|
167
|
+ }, function (err) {
|
|
168
|
+ if (err === ConnectionErrors.PASSWORD_REQUIRED) {
|
|
169
|
+ authDialog.displayError(err);
|
|
170
|
+ } else {
|
|
171
|
+ authDialog.close();
|
|
172
|
+ reject(err);
|
|
173
|
+ }
|
|
174
|
+ });
|
|
175
|
+ }
|
|
176
|
+ );
|
|
177
|
+ });
|
|
178
|
+}
|
|
179
|
+
|
|
180
|
+/**
|
|
181
|
+ * Show Authentication Dialog and try to connect with new credentials.
|
|
182
|
+ * If failed to connect because of PASSWORD_REQUIRED error
|
|
183
|
+ * then ask for password again.
|
|
184
|
+ * @param {string} [roomName] name of the conference room
|
|
185
|
+ * @param {function(id, password, roomName)} [connect] function that returns
|
|
186
|
+ * a Promise which resolves with JitsiConnection or fails with one of
|
|
187
|
+ * ConnectionErrors.
|
|
188
|
+ * @returns {Promise<JitsiConnection>}
|
|
189
|
+ */
|
|
190
|
+function requestAuth(roomName, connect) {
|
|
191
|
+ return showXmppPasswordPrompt(roomName, connect);
|
|
192
|
+}
|
|
193
|
+
|
160
|
194
|
|
161
|
195
|
export default {
|
162
|
196
|
authenticate,
|
163
|
197
|
requireAuth,
|
|
198
|
+ requestAuth,
|
164
|
199
|
closeAuth,
|
165
|
200
|
logout
|
166
|
201
|
};
|