瀏覽代碼

fix(authentication): removed old LoginDialog.js file, fixed redirection to the external auth and created actions.any.js (#9049)

* fix(authentication) login dialog now closes when connection is established

* fix(authentication) fixed shibboleth auth

* fix(authentication) renamed authenticateExternal func to authenticate and updated its logic

* fix(authentication)removed logindialog.js and created actions.any

* fix(authentication) removed focus from externalauthwindow

* fix(authentication) removed private sign from some actions and added openLoginDialog to actions.any

* fix(authentication) exported all from actions.any

* fix(authentication) reverted change regarding externalAuth

* fix(authentication) fixed indentation
j8
Calinteodor 4 年之前
父節點
當前提交
98658f573c
沒有連結到貢獻者的電子郵件帳戶。

+ 6
- 1
conference.js 查看文件

@@ -312,6 +312,11 @@ class ConferenceConnector {
312 312
                 room.join();
313 313
             }, 5000);
314 314
 
315
+            const { password }
316
+                = APP.store.getState()['features/base/conference'];
317
+
318
+            AuthHandler.requireAuth(room, password);
319
+
315 320
             break;
316 321
         }
317 322
 
@@ -2278,7 +2283,7 @@ export default {
2278 2283
         });
2279 2284
 
2280 2285
         APP.UI.addListener(UIEvents.AUTH_CLICKED, () => {
2281
-            AuthHandler.authenticateExternal(room);
2286
+            AuthHandler.authenticate(room);
2282 2287
         });
2283 2288
 
2284 2289
         APP.UI.addListener(

+ 0
- 2
connection.js 查看文件

@@ -4,7 +4,6 @@ import { jitsiLocalStorage } from '@jitsi/js-utils';
4 4
 import Logger from 'jitsi-meet-logger';
5 5
 
6 6
 import { redirectToTokenAuthService } from './modules/UI/authentication/AuthHandler';
7
-import { hideLoginDialog } from './react/features/authentication/actions.web';
8 7
 import { LoginDialog } from './react/features/authentication/components';
9 8
 import { isTokenAuthEnabled } from './react/features/authentication/functions';
10 9
 import {
@@ -243,7 +242,6 @@ function requestAuth(roomName) {
243 242
 
244 243
     return new Promise(resolve => {
245 244
         const onSuccess = connection => {
246
-            APP.store.dispatch(hideLoginDialog());
247 245
             resolve(connection);
248 246
         };
249 247
 

+ 1
- 0
lang/main.json 查看文件

@@ -259,6 +259,7 @@
259 259
         "muteParticipantsVideoTitle": "Disable camera of this participant?",
260 260
         "muteParticipantsVideoBody": "You won't be able to turn the camera back on, but they can turn it back on at any time.",
261 261
         "Ok": "OK",
262
+        "password": "Password",
262 263
         "passwordLabel": "The meeting has been locked by a participant. Please enter the $t(lockRoomPassword) to join.",
263 264
         "passwordNotSupported": "Setting a meeting $t(lockRoomPassword) is not supported.",
264 265
         "passwordNotSupportedTitle": "$t(lockRoomPasswordUppercase) not supported",

+ 30
- 3
modules/UI/authentication/AuthHandler.js 查看文件

@@ -3,15 +3,21 @@
3 3
 import Logger from 'jitsi-meet-logger';
4 4
 
5 5
 import { openConnection } from '../../../connection';
6
+import {
7
+    openAuthDialog,
8
+    openLoginDialog } from '../../../react/features/authentication/actions.web';
9
+import { WaitForOwnerDialog } from '../../../react/features/authentication/components';
6 10
 import {
7 11
     isTokenAuthEnabled,
8 12
     getTokenAuthUrl
9 13
 } from '../../../react/features/authentication/functions';
14
+import { isDialogOpen } from '../../../react/features/base/dialog';
10 15
 import { setJWT } from '../../../react/features/base/jwt';
11 16
 import UIUtil from '../util/UIUtil';
12 17
 
13 18
 import LoginDialog from './LoginDialog';
14 19
 
20
+
15 21
 let externalAuthWindow;
16 22
 declare var APP: Object;
17 23
 
@@ -33,6 +39,7 @@ function doExternalAuth(room, lockPassword) {
33 39
 
34 40
         return;
35 41
     }
42
+
36 43
     if (room.isJoined()) {
37 44
         let getUrl;
38 45
 
@@ -158,18 +165,37 @@ function initJWTTokenListener(room) {
158 165
 }
159 166
 
160 167
 /**
168
+ * Authenticate for the conference.
161 169
  * Uses external service for auth if conference supports that.
162 170
  * @param {JitsiConference} room
163 171
  * @param {string} [lockPassword] password to use if the conference is locked
164 172
  */
165
-function authenticateExternal(room: Object, lockPassword: string) {
173
+function authenticate(room: Object, lockPassword: string) {
166 174
     const config = APP.store.getState()['features/base/config'];
167 175
 
168 176
     if (isTokenAuthEnabled(config) || room.isExternalAuthEnabled()) {
169 177
         doExternalAuth(room, lockPassword);
178
+    } else {
179
+        APP.store.dispatch(openLoginDialog());
170 180
     }
171 181
 }
172 182
 
183
+/**
184
+ * Notify user that authentication is required to create the conference.
185
+ * @param {JitsiConference} room
186
+ * @param {string} [lockPassword] password to use if the conference is locked
187
+ */
188
+function requireAuth(room: Object, lockPassword: string) {
189
+    if (!isDialogOpen(APP.store, WaitForOwnerDialog)) {
190
+        return;
191
+    }
192
+
193
+    APP.store.dispatch(
194
+        openAuthDialog(
195
+        room.getName(), authenticate.bind(null, room, lockPassword))
196
+    );
197
+}
198
+
173 199
 /**
174 200
  * De-authenticate local user.
175 201
  *
@@ -191,6 +217,7 @@ function logout(room: Object) {
191 217
 }
192 218
 
193 219
 export default {
194
-    authenticateExternal,
195
-    logout
220
+    authenticate,
221
+    logout,
222
+    requireAuth
196 223
 };

+ 5
- 191
modules/UI/authentication/LoginDialog.js 查看文件

@@ -1,202 +1,16 @@
1
-/* global $, APP, config */
1
+// @flow
2 2
 
3
-import { toJid } from '../../../react/features/base/connection/functions';
4
-import {
5
-    JitsiConnectionErrors
6
-} from '../../../react/features/base/lib-jitsi-meet';
7
-
8
-/**
9
- * Build html for "password required" dialog.
10
- * @returns {string} html string
11
- */
12
-function getPasswordInputHtml() {
13
-    const placeholder = config.hosts.authdomain
14
-        ? 'user identity'
15
-        : 'user@domain.net';
16
-
17
-    return `
18
-        <input name="username" type="text"
19
-               class="input-control"
20
-               data-i18n="[placeholder]dialog.user"
21
-               placeholder=${placeholder} autofocus>
22
-        <input name="password" type="password"
23
-               class="input-control"
24
-               data-i18n="[placeholder]dialog.userPassword">`;
25
-}
26
-
27
-/**
28
- * Generate cancel button config for the dialog.
29
- * @returns {Object}
30
- */
31
-function cancelButton() {
32
-    return {
33
-        title: APP.translation.generateTranslationHTML('dialog.Cancel'),
34
-        value: false
35
-    };
36
-}
37
-
38
-/**
39
- * Auth dialog for JitsiConnection which supports retries.
40
- * If no cancelCallback provided then there will be
41
- * no cancel button on the dialog.
42
- *
43
- * @class LoginDialog
44
- * @constructor
45
- *
46
- * @param {function(jid, password)} successCallback
47
- * @param {function} [cancelCallback] callback to invoke if user canceled.
48
- */
49
-function LoginDialog(successCallback, cancelCallback) {
50
-    const loginButtons = [ {
51
-        title: APP.translation.generateTranslationHTML('dialog.Ok'),
52
-        value: true
53
-    } ];
54
-    const finishedButtons = [ {
55
-        title: APP.translation.generateTranslationHTML('dialog.retry'),
56
-        value: 'retry'
57
-    } ];
58
-
59
-    // show "cancel" button only if cancelCallback provided
60
-    if (cancelCallback) {
61
-        loginButtons.push(cancelButton());
62
-        finishedButtons.push(cancelButton());
63
-    }
64
-
65
-    const states = {
66
-        login: {
67
-            buttons: loginButtons,
68
-            focus: ':input:first',
69
-            html: getPasswordInputHtml(),
70
-            titleKey: 'dialog.passwordRequired',
71
-
72
-            submit(e, v, m, f) { // eslint-disable-line max-params
73
-                e.preventDefault();
74
-                if (v) {
75
-                    const jid = f.username;
76
-                    const password = f.password;
77
-
78
-                    if (jid && password) {
79
-                        // eslint-disable-next-line no-use-before-define
80
-                        connDialog.goToState('connecting');
81
-                        successCallback(toJid(jid, config.hosts), password);
82
-                    }
83
-                } else {
84
-                    // User cancelled
85
-                    cancelCallback();
86
-                }
87
-            }
88
-        },
89
-        connecting: {
90
-            buttons: [],
91
-            defaultButton: 0,
92
-            html: '<div id="connectionStatus"></div>',
93
-            titleKey: 'dialog.connecting'
94
-        },
95
-        finished: {
96
-            buttons: finishedButtons,
97
-            defaultButton: 0,
98
-            html: '<div id="errorMessage"></div>',
99
-            titleKey: 'dialog.error',
100
-
101
-            submit(e, v) {
102
-                e.preventDefault();
103
-                if (v === 'retry') {
104
-                    // eslint-disable-next-line no-use-before-define
105
-                    connDialog.goToState('login');
106
-                } else {
107
-                    // User cancelled
108
-                    cancelCallback();
109
-                }
110
-            }
111
-        }
112
-    };
113
-    const connDialog = APP.UI.messageHandler.openDialogWithStates(
114
-        states,
115
-        {
116
-            closeText: '',
117
-            persistent: true,
118
-            zIndex: 1020
119
-        },
120
-        null
121
-    );
122
-
123
-    /**
124
-     * Displays error message in 'finished' state which allows either to cancel
125
-     * or retry.
126
-     * @param error the key to the error to be displayed.
127
-     * @param options the options to the error message (optional)
128
-     */
129
-    this.displayError = function(error, options) {
130
-
131
-        const finishedState = connDialog.getState('finished');
132
-
133
-        const errorMessageElem = finishedState.find('#errorMessage');
134
-
135
-        let messageKey;
136
-
137
-        if (error === JitsiConnectionErrors.PASSWORD_REQUIRED) {
138
-            // this is a password required error, as login window was already
139
-            // open once, this means username or password is wrong
140
-            messageKey = 'dialog.incorrectPassword';
141
-        } else {
142
-            messageKey = 'dialog.connectErrorWithMsg';
143
-
144
-            if (!options) {
145
-                options = {};// eslint-disable-line no-param-reassign
146
-            }
147
-
148
-            options.msg = error;
149
-        }
150
-
151
-        errorMessageElem.attr('data-i18n', messageKey);
152
-
153
-        APP.translation.translateElement($(errorMessageElem), options);
154
-
155
-        connDialog.goToState('finished');
156
-    };
157
-
158
-    /**
159
-     *  Show message as connection status.
160
-     * @param {string} messageKey the key to the message
161
-     */
162
-    this.displayConnectionStatus = function(messageKey) {
163
-        const connectingState = connDialog.getState('connecting');
164
-
165
-        const connectionStatus = connectingState.find('#connectionStatus');
166
-
167
-        connectionStatus.attr('data-i18n', messageKey);
168
-        APP.translation.translateElement($(connectionStatus));
169
-    };
170
-
171
-    /**
172
-     * Closes LoginDialog.
173
-     */
174
-    this.close = function() {
175
-        connDialog.close();
176
-    };
177
-}
3
+declare var APP: Object;
178 4
 
179 5
 export default {
180 6
 
181
-    /**
182
-     * Show new auth dialog for JitsiConnection.
183
-     *
184
-     * @param {function(jid, password)} successCallback
185
-     * @param {function} [cancelCallback] callback to invoke if user canceled.
186
-     *
187
-     * @returns {LoginDialog}
188
-     */
189
-    showAuthDialog(successCallback, cancelCallback) {
190
-        return new LoginDialog(successCallback, cancelCallback);
191
-    },
192
-
193 7
     /**
194 8
      * Show notification that external auth is required (using provided url).
195
-     * @param {string} url URL to use for external auth.
196
-     * @param {function} callback callback to invoke when auth popup is closed.
9
+     * @param {string} url - URL to use for external auth.
10
+     * @param {function} callback - callback to invoke when auth popup is closed.
197 11
      * @returns auth dialog
198 12
      */
199
-    showExternalAuthDialog(url, callback) {
13
+    showExternalAuthDialog(url: string, callback: ?Function) {
200 14
         const dialog = APP.UI.messageHandler.openCenteredPopup(
201 15
             url, 910, 660,
202 16
 

+ 182
- 0
react/features/authentication/actions.any.js 查看文件

@@ -0,0 +1,182 @@
1
+// @flow
2
+
3
+import type { Dispatch } from 'redux';
4
+
5
+import { checkIfCanJoin } from '../base/conference';
6
+import { openDialog } from '../base/dialog';
7
+
8
+import {
9
+    STOP_WAIT_FOR_OWNER,
10
+    UPGRADE_ROLE_FINISHED,
11
+    UPGRADE_ROLE_STARTED, WAIT_FOR_OWNER
12
+} from './actionTypes';
13
+import { LoginDialog, WaitForOwnerDialog } from './components';
14
+import logger from './logger';
15
+
16
+/**
17
+ * Initiates authenticating and upgrading the role of the local participant to
18
+ * moderator which will allow to create and join a new conference on an XMPP
19
+ * password + guest access configuration. Refer to {@link LoginDialog} for more
20
+ * info.
21
+ *
22
+ * @param {string} id - The XMPP user's ID (e.g. {@code user@domain.com}).
23
+ * @param {string} password - The XMPP user's password.
24
+ * @param {JitsiConference} conference - The conference for which the local
25
+ * participant's role will be upgraded.
26
+ * @returns {Function}
27
+ */
28
+export function authenticateAndUpgradeRole(
29
+        id: string,
30
+        password: string,
31
+        conference: Object) {
32
+    return (dispatch: Dispatch<any>, getState: Function) => {
33
+        const { password: roomPassword }
34
+            = getState()['features/base/conference'];
35
+        const process
36
+            = conference.authenticateAndUpgradeRole({
37
+                id,
38
+                password,
39
+                roomPassword,
40
+
41
+                onLoginSuccessful() {
42
+                // When the login succeeds, the process has completed half
43
+                // of its job (i.e. 0.5).
44
+                    return dispatch(_upgradeRoleFinished(process, 0.5));
45
+                }
46
+            });
47
+
48
+        dispatch(_upgradeRoleStarted(process));
49
+        process.then(
50
+            /* onFulfilled */ () => dispatch(_upgradeRoleFinished(process, 1)),
51
+            /* onRejected */ error => {
52
+                // The lack of an error signals a cancellation.
53
+                if (error.authenticationError || error.connectionError) {
54
+                    logger.error('authenticateAndUpgradeRole failed', error);
55
+                }
56
+
57
+                dispatch(_upgradeRoleFinished(process, error));
58
+            });
59
+
60
+        return process;
61
+    };
62
+}
63
+
64
+
65
+/**
66
+ * Signals that the process of authenticating and upgrading the local
67
+ * participant's role has finished either with success or with a specific error.
68
+ *
69
+ * @param {Object} thenableWithCancel - The process of authenticating and
70
+ * upgrading the local participant's role.
71
+ * @param {Object} progressOrError - If the value is a {@code number}, then the
72
+ * process of authenticating and upgrading the local participant's role has
73
+ * succeeded in one of its two/multiple steps; otherwise, it has failed with the
74
+ * specified error. Refer to {@link JitsiConference#authenticateAndUpgradeRole}
75
+ * in lib-jitsi-meet for the error details.
76
+ * @private
77
+ * @returns {{
78
+ *     type: UPGRADE_ROLE_FINISHED,
79
+ *     error: ?Object,
80
+ *     progress: number
81
+ * }}
82
+ */
83
+function _upgradeRoleFinished(
84
+        thenableWithCancel,
85
+        progressOrError: number | Object) {
86
+    let error;
87
+    let progress;
88
+
89
+    if (typeof progressOrError === 'number') {
90
+        progress = progressOrError;
91
+    } else {
92
+        // Make the specified error object resemble an Error instance (to the
93
+        // extent that jitsi-meet needs it).
94
+        const {
95
+            authenticationError,
96
+            connectionError,
97
+            ...other
98
+        } = progressOrError;
99
+
100
+        error = {
101
+            name: authenticationError || connectionError,
102
+            ...other
103
+        };
104
+        progress = authenticationError ? 0.5 : 0;
105
+    }
106
+
107
+    return {
108
+        type: UPGRADE_ROLE_FINISHED,
109
+        error,
110
+        progress,
111
+        thenableWithCancel
112
+    };
113
+}
114
+
115
+/**
116
+ * Signals that a process of authenticating and upgrading the local
117
+ * participant's role has started.
118
+ *
119
+ * @param {Object} thenableWithCancel - The process of authenticating and
120
+ * upgrading the local participant's role.
121
+ * @private
122
+ * @returns {{
123
+ *     type: UPGRADE_ROLE_STARTED,
124
+ *     thenableWithCancel: Object
125
+ * }}
126
+ */
127
+function _upgradeRoleStarted(thenableWithCancel) {
128
+    return {
129
+        type: UPGRADE_ROLE_STARTED,
130
+        thenableWithCancel
131
+    };
132
+}
133
+
134
+/**
135
+ * Opens {@link WaitForOnwerDialog}.
136
+ *
137
+ * @protected
138
+ * @returns {Action}
139
+ */
140
+export function openWaitForOwnerDialog() {
141
+    return openDialog(WaitForOwnerDialog);
142
+}
143
+
144
+/**
145
+ * Stops waiting for the conference owner.
146
+ *
147
+ * @returns {{
148
+ *     type: STOP_WAIT_FOR_OWNER
149
+ * }}
150
+ */
151
+export function stopWaitForOwner() {
152
+    return {
153
+        type: STOP_WAIT_FOR_OWNER
154
+    };
155
+}
156
+
157
+/**
158
+ * Called when Jicofo rejects to create the room for anonymous user. Will
159
+ * start the process of "waiting for the owner" by periodically trying to join
160
+ * the room every five seconds.
161
+ *
162
+ * @returns {Function}
163
+ */
164
+export function waitForOwner() {
165
+    return (dispatch: Dispatch<any>) =>
166
+        dispatch({
167
+            type: WAIT_FOR_OWNER,
168
+            handler: () => dispatch(checkIfCanJoin()),
169
+            timeoutMs: 5000
170
+        });
171
+}
172
+
173
+/**
174
+ * Opens {@link LoginDialog} which will ask to enter username and password
175
+ * for the current conference.
176
+ *
177
+ * @protected
178
+ * @returns {Action}
179
+ */
180
+export function openLoginDialog() {
181
+    return openDialog(LoginDialog);
182
+}

+ 4
- 175
react/features/authentication/actions.native.js 查看文件

@@ -3,68 +3,14 @@
3 3
 import type { Dispatch } from 'redux';
4 4
 
5 5
 import { appNavigate } from '../app/actions';
6
-import { checkIfCanJoin, conferenceLeft } from '../base/conference/actions';
6
+import { conferenceLeft } from '../base/conference/actions';
7 7
 import { connectionFailed } from '../base/connection/actions.native';
8
-import { openDialog } from '../base/dialog/actions';
9 8
 import { set } from '../base/redux';
10 9
 
11
-import {
12
-    CANCEL_LOGIN,
13
-    STOP_WAIT_FOR_OWNER,
14
-    UPGRADE_ROLE_FINISHED,
15
-    UPGRADE_ROLE_STARTED,
16
-    WAIT_FOR_OWNER
17
-} from './actionTypes';
18
-import { LoginDialog, WaitForOwnerDialog } from './components';
19
-import logger from './logger';
10
+import { CANCEL_LOGIN } from './actionTypes';
11
+import { stopWaitForOwner } from './actions.any';
20 12
 
21
-/**
22
- * Initiates authenticating and upgrading the role of the local participant to
23
- * moderator which will allow to create and join a new conference on an XMPP
24
- * password + guest access configuration. Refer to {@link LoginDialog} for more
25
- * info.
26
- *
27
- * @param {string} id - The XMPP user's ID (e.g. {@code user@domain.com}).
28
- * @param {string} password - The XMPP user's password.
29
- * @param {JitsiConference} conference - The conference for which the local
30
- * participant's role will be upgraded.
31
- * @returns {Function}
32
- */
33
-export function authenticateAndUpgradeRole(
34
-        id: string,
35
-        password: string,
36
-        conference: Object) {
37
-    return (dispatch: Dispatch<any>, getState: Function) => {
38
-        const { password: roomPassword }
39
-            = getState()['features/base/conference'];
40
-        const process
41
-            = conference.authenticateAndUpgradeRole({
42
-                id,
43
-                password,
44
-                roomPassword,
45
-
46
-                onLoginSuccessful() {
47
-                    // When the login succeeds, the process has completed half
48
-                    // of its job (i.e. 0.5).
49
-                    return dispatch(_upgradeRoleFinished(process, 0.5));
50
-                }
51
-            });
52
-
53
-        dispatch(_upgradeRoleStarted(process));
54
-        process.then(
55
-            /* onFulfilled */ () => dispatch(_upgradeRoleFinished(process, 1)),
56
-            /* onRejected */ error => {
57
-                // The lack of an error signals a cancellation.
58
-                if (error.authenticationError || error.connectionError) {
59
-                    logger.error('authenticateAndUpgradeRole failed', error);
60
-                }
61
-
62
-                dispatch(_upgradeRoleFinished(process, error));
63
-            });
64
-
65
-        return process;
66
-    };
67
-}
13
+export * from './actions.any';
68 14
 
69 15
 /**
70 16
  * Cancels {@ink LoginDialog}.
@@ -118,121 +64,4 @@ export function cancelWaitForOwner() {
118 64
     };
119 65
 }
120 66
 
121
-/**
122
- * Opens {@link LoginDialog} which will ask to enter username and password
123
- * for the current conference.
124
- *
125
- * @protected
126
- * @returns {Action}
127
- */
128
-export function _openLoginDialog() {
129
-    return openDialog(LoginDialog);
130
-}
131
-
132
-/**
133
- * Opens {@link WaitForOnwerDialog}.
134
- *
135
- * @protected
136
- * @returns {Action}
137
- */
138
-export function _openWaitForOwnerDialog() {
139
-    return openDialog(WaitForOwnerDialog);
140
-}
141
-
142
-/**
143
- * Stops waiting for the conference owner.
144
- *
145
- * @returns {{
146
- *     type: STOP_WAIT_FOR_OWNER
147
- * }}
148
- */
149
-export function stopWaitForOwner() {
150
-    return {
151
-        type: STOP_WAIT_FOR_OWNER
152
-    };
153
-}
154
-
155
-/**
156
- * Signals that the process of authenticating and upgrading the local
157
- * participant's role has finished either with success or with a specific error.
158
- *
159
- * @param {Object} thenableWithCancel - The process of authenticating and
160
- * upgrading the local participant's role.
161
- * @param {Object} progressOrError - If the value is a {@code number}, then the
162
- * process of authenticating and upgrading the local participant's role has
163
- * succeeded in one of its two/multiple steps; otherwise, it has failed with the
164
- * specified error. Refer to {@link JitsiConference#authenticateAndUpgradeRole}
165
- * in lib-jitsi-meet for the error details.
166
- * @private
167
- * @returns {{
168
- *     type: UPGRADE_ROLE_FINISHED,
169
- *     error: ?Object,
170
- *     progress: number
171
- * }}
172
- */
173
-function _upgradeRoleFinished(
174
-        thenableWithCancel,
175
-        progressOrError: number | Object) {
176
-    let error;
177
-    let progress;
178
-
179
-    if (typeof progressOrError === 'number') {
180
-        progress = progressOrError;
181
-    } else {
182
-        // Make the specified error object resemble an Error instance (to the
183
-        // extent that jitsi-meet needs it).
184
-        const {
185
-            authenticationError,
186
-            connectionError,
187
-            ...other
188
-        } = progressOrError;
189
-
190
-        error = {
191
-            name: authenticationError || connectionError,
192
-            ...other
193
-        };
194
-        progress = authenticationError ? 0.5 : 0;
195
-    }
196
-
197
-    return {
198
-        type: UPGRADE_ROLE_FINISHED,
199
-        error,
200
-        progress,
201
-        thenableWithCancel
202
-    };
203
-}
204
-
205
-/**
206
- * Signals that a process of authenticating and upgrading the local
207
- * participant's role has started.
208
- *
209
- * @param {Object} thenableWithCancel - The process of authenticating and
210
- * upgrading the local participant's role.
211
- * @private
212
- * @returns {{
213
- *     type: UPGRADE_ROLE_STARTED,
214
- *     thenableWithCancel: Object
215
- * }}
216
- */
217
-function _upgradeRoleStarted(thenableWithCancel) {
218
-    return {
219
-        type: UPGRADE_ROLE_STARTED,
220
-        thenableWithCancel
221
-    };
222
-}
223 67
 
224
-/**
225
- * Called when Jicofo rejects to create the room for anonymous user. Will
226
- * start the process of "waiting for the owner" by periodically trying to join
227
- * the room every five seconds.
228
- *
229
- * @returns {Function}
230
- */
231
-export function waitForOwner() {
232
-    return (dispatch: Dispatch<any>) =>
233
-        dispatch({
234
-            type: WAIT_FOR_OWNER,
235
-            handler: () => dispatch(checkIfCanJoin()),
236
-            timeoutMs: 5000
237
-        });
238
-}

+ 12
- 14
react/features/authentication/actions.web.js 查看文件

@@ -8,6 +8,8 @@ import {
8 8
 } from './actionTypes';
9 9
 import { WaitForOwnerDialog, LoginDialog } from './components';
10 10
 
11
+export * from './actions.any';
12
+
11 13
 /**
12 14
  * Cancels {@ink LoginDialog}.
13 15
  *
@@ -43,25 +45,21 @@ export function hideLoginDialog() {
43 45
     return hideDialog(LoginDialog);
44 46
 }
45 47
 
46
-/**
47
- * Shows a authentication dialog where the local participant
48
- * should authenticate.
49
- *
50
- * @returns {Function}.
51
- */
52
-export function openLoginDialog() {
53
-    return openDialog(LoginDialog);
54
-}
55
-
56 48
 /**
57 49
  * Shows a notification dialog that authentication is required to create the.
58
- * Conference, so the local participant should authenticate or wait for a
59
- * host.
50
+ * Conference.
51
+ * This is used for external auth.
52
+ *
53
+ * @param {string} room - The room name.
54
+ * @param {Function} onAuthNow - The function to be invoked when external authentication.
60 55
  *
61 56
  * @returns {Function}.
62 57
  */
63
-export function openWaitForOwnerDialog() {
64
-    return openDialog(WaitForOwnerDialog);
58
+export function openAuthDialog(room: String, onAuthNow: ?Function) {
59
+    return openDialog(WaitForOwnerDialog, {
60
+        room,
61
+        onAuthNow
62
+    });
65 63
 }
66 64
 
67 65
 

+ 2
- 2
react/features/authentication/components/native/WaitForOwnerDialog.js 查看文件

@@ -6,7 +6,7 @@ import type { Dispatch } from 'redux';
6 6
 import { ConfirmDialog } from '../../../base/dialog';
7 7
 import { translate } from '../../../base/i18n';
8 8
 import { connect } from '../../../base/redux';
9
-import { cancelWaitForOwner, _openLoginDialog } from '../../actions.native';
9
+import { openLoginDialog, cancelWaitForOwner } from '../../actions.native';
10 10
 
11 11
 /**
12 12
  * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
@@ -97,7 +97,7 @@ class WaitForOwnerDialog extends Component<Props> {
97 97
      * @returns {void}
98 98
      */
99 99
     _onLogin() {
100
-        this.props.dispatch(_openLoginDialog());
100
+        this.props.dispatch(openLoginDialog());
101 101
     }
102 102
 }
103 103
 

+ 3
- 3
react/features/authentication/components/web/LoginDialog.js 查看文件

@@ -10,8 +10,7 @@ import { Dialog } from '../../../base/dialog';
10 10
 import { translate, translateToHTML } from '../../../base/i18n';
11 11
 import { JitsiConnectionErrors } from '../../../base/lib-jitsi-meet';
12 12
 import { connect as reduxConnect } from '../../../base/redux';
13
-import { authenticateAndUpgradeRole } from '../../actions.native';
14
-import { cancelLogin } from '../../actions.web';
13
+import { authenticateAndUpgradeRole, cancelLogin } from '../../actions.web';
15 14
 
16 15
 /**
17 16
  * The type of the React {@code Component} props of {@link LoginDialog}.
@@ -197,7 +196,7 @@ class LoginDialog extends Component<Props, State> {
197 196
         const messageOptions = {};
198 197
         let messageKey;
199 198
 
200
-        if (progress && progress >= 0.5) {
199
+        if (progress && progress < 1) {
201 200
             messageKey = t('connection.FETCH_SESSION_ID');
202 201
         } else if (error) {
203 202
             const { name } = error;
@@ -271,6 +270,7 @@ class LoginDialog extends Component<Props, State> {
271 270
                     label = { t('dialog.userPassword') }
272 271
                     name = 'password'
273 272
                     onChange = { this._onChange }
273
+                    placeholder = { t('dialog.password') }
274 274
                     shouldFitContainer = { true }
275 275
                     type = 'password'
276 276
                     value = { password } />

+ 5
- 5
react/features/authentication/components/web/WaitForOwnerDialog.js 查看文件

@@ -6,7 +6,7 @@ import type { Dispatch } from 'redux';
6 6
 import { Dialog } from '../../../base/dialog';
7 7
 import { translate, translateToHTML } from '../../../base/i18n';
8 8
 import { connect } from '../../../base/redux';
9
-import { openLoginDialog, cancelWaitForOwner } from '../../actions.web';
9
+import { cancelWaitForOwner } from '../../actions.web';
10 10
 
11 11
 /**
12 12
  * The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
@@ -76,9 +76,9 @@ class WaitForOwnerDialog extends PureComponent<Props> {
76 76
      * @returns {void}
77 77
      */
78 78
     _onIAmHost() {
79
-        const { dispatch } = this.props;
79
+        const { onAuthNow } = this.props;
80 80
 
81
-        dispatch(openLoginDialog());
81
+        onAuthNow && onAuthNow();
82 82
     }
83 83
 
84 84
     /**
@@ -88,7 +88,7 @@ class WaitForOwnerDialog extends PureComponent<Props> {
88 88
      */
89 89
     render() {
90 90
         const {
91
-            _room,
91
+            _room: room,
92 92
             t
93 93
         } = this.props;
94 94
 
@@ -102,7 +102,7 @@ class WaitForOwnerDialog extends PureComponent<Props> {
102 102
                 <span>
103 103
                     {
104 104
                         translateToHTML(
105
-                            t, 'dialog.WaitForHostMsg', { room: _room })
105
+                            t, 'dialog.WaitForHostMsg', { room })
106 106
                     }
107 107
                 </span>
108 108
             </Dialog>

+ 6
- 7
react/features/authentication/middleware.native.js 查看文件

@@ -22,11 +22,10 @@ import {
22 22
     WAIT_FOR_OWNER
23 23
 } from './actionTypes';
24 24
 import {
25
-    _openLoginDialog,
26
-    _openWaitForOwnerDialog,
25
+    openLoginDialog,
26
+    openWaitForOwnerDialog,
27 27
     stopWaitForOwner,
28
-    waitForOwner
29
-} from './actions.native';
28
+    waitForOwner } from './actions.native';
30 29
 import { LoginDialog, WaitForOwnerDialog } from './components';
31 30
 
32 31
 /**
@@ -54,7 +53,7 @@ MiddlewareRegistry.register(store => next => action => {
54 53
                 // Instead of hiding show the new one.
55 54
                 const result = next(action);
56 55
 
57
-                dispatch(_openWaitForOwnerDialog());
56
+                dispatch(openWaitForOwnerDialog());
58 57
 
59 58
                 return result;
60 59
             }
@@ -114,7 +113,7 @@ MiddlewareRegistry.register(store => next => action => {
114 113
                 && error.name === JitsiConnectionErrors.PASSWORD_REQUIRED
115 114
                 && typeof error.recoverable === 'undefined') {
116 115
             error.recoverable = true;
117
-            store.dispatch(_openLoginDialog());
116
+            store.dispatch(openLoginDialog());
118 117
         }
119 118
         break;
120 119
     }
@@ -134,7 +133,7 @@ MiddlewareRegistry.register(store => next => action => {
134 133
         // The WAIT_FOR_OWNER action is cyclic and we don't want to hide the
135 134
         // login dialog every few seconds.
136 135
         isDialogOpen(store, LoginDialog)
137
-            || store.dispatch(_openWaitForOwnerDialog());
136
+            || store.dispatch(openWaitForOwnerDialog());
138 137
         break;
139 138
     }
140 139
     }

+ 10
- 12
react/features/authentication/middleware.web.js 查看文件

@@ -19,12 +19,10 @@ import {
19 19
     WAIT_FOR_OWNER
20 20
 } from './actionTypes';
21 21
 import {
22
+    hideLoginDialog,
23
+    openWaitForOwnerDialog,
22 24
     stopWaitForOwner,
23 25
     waitForOwner
24
-} from './actions.native';
25
-import {
26
-    hideLoginDialog,
27
-    openWaitForOwnerDialog
28 26
 } from './actions.web';
29 27
 import { LoginDialog, WaitForOwnerDialog } from './components';
30 28
 
@@ -42,7 +40,7 @@ MiddlewareRegistry.register(store => next => action => {
42 40
 
43 41
     case CANCEL_LOGIN: {
44 42
         if (!isDialogOpen(store, WaitForOwnerDialog)) {
45
-            if (isWaitingForOwner(store)) {
43
+            if (_isWaitingForOwner(store)) {
46 44
                 store.dispatch(openWaitForOwnerDialog());
47 45
 
48 46
                 return next(action);
@@ -74,10 +72,10 @@ MiddlewareRegistry.register(store => next => action => {
74 72
     }
75 73
 
76 74
     case CONFERENCE_JOINED:
77
-        if (isWaitingForOwner(store)) {
75
+        if (_isWaitingForOwner(store)) {
78 76
             store.dispatch(stopWaitForOwner());
79 77
         }
80
-        store.dispatch(hideLoginDialog);
78
+        store.dispatch(hideLoginDialog());
81 79
         break;
82 80
 
83 81
     case CONFERENCE_LEFT:
@@ -85,16 +83,16 @@ MiddlewareRegistry.register(store => next => action => {
85 83
         break;
86 84
 
87 85
     case CONNECTION_ESTABLISHED:
88
-        store.dispatch(hideLoginDialog);
86
+        store.dispatch(hideLoginDialog());
89 87
         break;
90 88
 
91 89
     case STOP_WAIT_FOR_OWNER:
92
-        clearExistingWaitForOwnerTimeout(store);
90
+        _clearExistingWaitForOwnerTimeout(store);
93 91
         store.dispatch(hideDialog(WaitForOwnerDialog));
94 92
         break;
95 93
 
96 94
     case WAIT_FOR_OWNER: {
97
-        clearExistingWaitForOwnerTimeout(store);
95
+        _clearExistingWaitForOwnerTimeout(store);
98 96
 
99 97
         const { handler, timeoutMs } = action;
100 98
 
@@ -116,7 +114,7 @@ MiddlewareRegistry.register(store => next => action => {
116 114
  * @param {Object} store - The redux store.
117 115
  * @returns {void}
118 116
  */
119
-function clearExistingWaitForOwnerTimeout(
117
+function _clearExistingWaitForOwnerTimeout(
120 118
         { getState }: { getState: Function }) {
121 119
     const { waitForOwnerTimeoutID } = getState()['features/authentication'];
122 120
 
@@ -129,6 +127,6 @@ function clearExistingWaitForOwnerTimeout(
129 127
  * @param {Object} store - The redux store.
130 128
  * @returns {void}
131 129
  */
132
-function isWaitingForOwner({ getState }: { getState: Function }) {
130
+function _isWaitingForOwner({ getState }: { getState: Function }) {
133 131
     return getState()['features/authentication'].waitForOwnerTimeoutID;
134 132
 }

Loading…
取消
儲存