Browse Source

fix(LoginDialog.native): no 'password incorrect' initially

Do not show the 'Password is incorrect' message when the LoginDialog
opens for the first time.
master
paweldomas 8 years ago
parent
commit
f8b607e92e

+ 19
- 2
react/features/authentication/components/LoginDialog.native.js View File

66
          */
66
          */
67
         _error: PropTypes.string,
67
         _error: PropTypes.string,
68
 
68
 
69
+        /**
70
+         * The credential that the user has failed to authenticate with.
71
+         */
72
+        _errorCredentials: PropTypes.object,
73
+
69
         /**
74
         /**
70
          * Any extra details about the error provided by lib-jitsi-meet.
75
          * Any extra details about the error provided by lib-jitsi-meet.
71
          */
76
          */
113
         const {
118
         const {
114
             _connecting: connecting,
119
             _connecting: connecting,
115
             _error: error,
120
             _error: error,
121
+            _errorCredentials: errorCredentials,
116
             _errorDetails: errorDetails,
122
             _errorDetails: errorDetails,
117
             t
123
             t
118
         } = this.props;
124
         } = this.props;
121
         const messageOptions = {};
127
         const messageOptions = {};
122
 
128
 
123
         if (error === JitsiConnectionErrors.PASSWORD_REQUIRED) {
129
         if (error === JitsiConnectionErrors.PASSWORD_REQUIRED) {
124
-            messageKey = 'dialog.incorrectPassword';
130
+            // Show the message if there's been a user ID or password provided.
131
+            messageKey
132
+                = errorCredentials
133
+                        && (errorCredentials.jid || errorCredentials.password)
134
+                    ? 'dialog.incorrectPassword'
135
+                    : null;
125
         } else if (error) {
136
         } else if (error) {
126
             messageKey = 'dialog.connectErrorWithMsg';
137
             messageKey = 'dialog.connectErrorWithMsg';
127
             messageOptions.msg = `${error} ${errorDetails}`;
138
             messageOptions.msg = `${error} ${errorDetails}`;
147
                         value = { this.state.password } />
158
                         value = { this.state.password } />
148
                     <Text style = { styles.loginDialogText }>
159
                     <Text style = { styles.loginDialogText }>
149
                         {
160
                         {
150
-                            error
161
+                            messageKey
151
                                 ? t(messageKey, messageOptions)
162
                                 ? t(messageKey, messageOptions)
152
                                 : connecting
163
                                 : connecting
153
                                     ? t('connection.CONNECTING')
164
                                     ? t('connection.CONNECTING')
229
  *     _configHosts: Object,
240
  *     _configHosts: Object,
230
  *     _connecting: boolean,
241
  *     _connecting: boolean,
231
  *     _error: string,
242
  *     _error: string,
243
+ *     _errorCredentials: Object,
232
  *     _errorDetails: string
244
  *     _errorDetails: string
233
  * }}
245
  * }}
234
  */
246
  */
241
     const { hosts: configHosts } = state['features/base/config'];
253
     const { hosts: configHosts } = state['features/base/config'];
242
     const {
254
     const {
243
         connecting,
255
         connecting,
256
+        credentials,
244
         error: connectionError,
257
         error: connectionError,
245
         errorMessage: connectionErrorMessage
258
         errorMessage: connectionErrorMessage
246
     } = state['features/base/connection'];
259
     } = state['features/base/connection'];
247
 
260
 
248
     let error;
261
     let error;
262
+    let errorCredentials;
249
     let errorDetails;
263
     let errorDetails;
250
 
264
 
251
     if (connectionError) {
265
     if (connectionError) {
252
         error = connectionError;
266
         error = connectionError;
267
+        errorCredentials = credentials;
253
         errorDetails = connectionErrorMessage;
268
         errorDetails = connectionErrorMessage;
254
     } else if (upgradeRoleError) {
269
     } else if (upgradeRoleError) {
255
         error
270
         error
256
             = upgradeRoleError.connectionError
271
             = upgradeRoleError.connectionError
257
                 || upgradeRoleError.authenticationError;
272
                 || upgradeRoleError.authenticationError;
273
+        errorCredentials = upgradeRoleError.credentials;
258
         errorDetails = upgradeRoleError.message;
274
         errorDetails = upgradeRoleError.message;
259
     }
275
     }
260
 
276
 
263
         _configHosts: configHosts,
279
         _configHosts: configHosts,
264
         _connecting: Boolean(connecting) || Boolean(upgradeRoleInProgress),
280
         _connecting: Boolean(connecting) || Boolean(upgradeRoleInProgress),
265
         _error: error,
281
         _error: error,
282
+        _errorCredentials: errorCredentials,
266
         _errorDetails: errorDetails
283
         _errorDetails: errorDetails
267
     };
284
     };
268
 }
285
 }

+ 18
- 5
react/features/base/connection/actions.native.js View File

81
          * Rejects external promise when connection fails.
81
          * Rejects external promise when connection fails.
82
          *
82
          *
83
          * @param {JitsiConnectionErrors} err - Connection error.
83
          * @param {JitsiConnectionErrors} err - Connection error.
84
-         * @param {string} msg - Error message supplied by lib-jitsi-meet.
84
+         * @param {string} [msg] - Error message supplied by lib-jitsi-meet.
85
+         * @param {Object} [credentials] - The invalid credentials that were
86
+         * used to authenticate and the authentication failed.
87
+         * @param {string} [credentials.jid] - The XMPP user's ID.
88
+         * @param {string} [credentials.password] - The XMPP user's password.
85
          * @returns {void}
89
          * @returns {void}
86
          * @private
90
          * @private
87
          */
91
          */
88
-        function _onConnectionFailed(err, msg) {
92
+        function _onConnectionFailed(err, msg, credentials) {
89
             unsubscribe();
93
             unsubscribe();
90
             console.error('CONNECTION FAILED:', err, msg);
94
             console.error('CONNECTION FAILED:', err, msg);
91
-            dispatch(connectionFailed(connection, err, msg));
95
+            dispatch(connectionFailed(connection, err, msg, credentials));
92
         }
96
         }
93
 
97
 
94
         /**
98
         /**
163
     };
167
     };
164
 }
168
 }
165
 
169
 
170
+/* eslint-disable max-params */
171
+
166
 /**
172
 /**
167
  * Create an action for when the signaling connection could not be created.
173
  * Create an action for when the signaling connection could not be created.
168
  *
174
  *
169
  * @param {JitsiConnection} connection - The JitsiConnection which failed.
175
  * @param {JitsiConnection} connection - The JitsiConnection which failed.
170
  * @param {string} error - Error.
176
  * @param {string} error - Error.
171
- * @param {string} message - Error message.
177
+ * @param {string} [message] - Error message.
178
+ * @param {Object} [credentials] - The invalid credentials that failed
179
+ * the authentication.
172
  * @public
180
  * @public
173
  * @returns {{
181
  * @returns {{
174
  *     type: CONNECTION_FAILED,
182
  *     type: CONNECTION_FAILED,
175
  *     connection: JitsiConnection,
183
  *     connection: JitsiConnection,
184
+ *     credentials: Object,
176
  *     error: string,
185
  *     error: string,
177
  *     message: string
186
  *     message: string
178
  * }}
187
  * }}
180
 export function connectionFailed(
189
 export function connectionFailed(
181
         connection: Object,
190
         connection: Object,
182
         error: string,
191
         error: string,
183
-        message: ?string) {
192
+        message: ?string,
193
+        credentials: ?Object) {
184
     return {
194
     return {
185
         type: CONNECTION_FAILED,
195
         type: CONNECTION_FAILED,
186
         connection,
196
         connection,
197
+        credentials,
187
         error,
198
         error,
188
         message
199
         message
189
     };
200
     };
190
 }
201
 }
191
 
202
 
203
+/* eslint-enable max-params */
204
+
192
 /**
205
 /**
193
  * Constructs options to be passed to the constructor of {@code JitsiConnection}
206
  * Constructs options to be passed to the constructor of {@code JitsiConnection}
194
  * based on the redux state.
207
  * based on the redux state.

+ 4
- 1
react/features/base/connection/reducer.js View File

93
  */
93
  */
94
 function _connectionFailed(
94
 function _connectionFailed(
95
         state: Object,
95
         state: Object,
96
-        { connection, error, message }: {
96
+        { connection, credentials, error, message }: {
97
             connection: Object,
97
             connection: Object,
98
+            credentials: ?Object,
98
             error: string,
99
             error: string,
99
             message: ?string
100
             message: ?string
100
         }) {
101
         }) {
105
     return assign(state, {
106
     return assign(state, {
106
         connecting: undefined,
107
         connecting: undefined,
107
         connection: undefined,
108
         connection: undefined,
109
+        credentials,
108
         error,
110
         error,
109
         errorMessage: message
111
         errorMessage: message
110
     });
112
     });
125
         { connection }: { connection: Object }) {
127
         { connection }: { connection: Object }) {
126
     return assign(state, {
128
     return assign(state, {
127
         connecting: connection,
129
         connecting: connection,
130
+        credentials: undefined,
128
         error: undefined,
131
         error: undefined,
129
         errorMessage: undefined
132
         errorMessage: undefined
130
     });
133
     });

Loading…
Cancel
Save