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,6 +66,11 @@ class LoginDialog extends Component {
66 66
          */
67 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 75
          * Any extra details about the error provided by lib-jitsi-meet.
71 76
          */
@@ -113,6 +118,7 @@ class LoginDialog extends Component {
113 118
         const {
114 119
             _connecting: connecting,
115 120
             _error: error,
121
+            _errorCredentials: errorCredentials,
116 122
             _errorDetails: errorDetails,
117 123
             t
118 124
         } = this.props;
@@ -121,7 +127,12 @@ class LoginDialog extends Component {
121 127
         const messageOptions = {};
122 128
 
123 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 136
         } else if (error) {
126 137
             messageKey = 'dialog.connectErrorWithMsg';
127 138
             messageOptions.msg = `${error} ${errorDetails}`;
@@ -147,7 +158,7 @@ class LoginDialog extends Component {
147 158
                         value = { this.state.password } />
148 159
                     <Text style = { styles.loginDialogText }>
149 160
                         {
150
-                            error
161
+                            messageKey
151 162
                                 ? t(messageKey, messageOptions)
152 163
                                 : connecting
153 164
                                     ? t('connection.CONNECTING')
@@ -229,6 +240,7 @@ class LoginDialog extends Component {
229 240
  *     _configHosts: Object,
230 241
  *     _connecting: boolean,
231 242
  *     _error: string,
243
+ *     _errorCredentials: Object,
232 244
  *     _errorDetails: string
233 245
  * }}
234 246
  */
@@ -241,20 +253,24 @@ function _mapStateToProps(state) {
241 253
     const { hosts: configHosts } = state['features/base/config'];
242 254
     const {
243 255
         connecting,
256
+        credentials,
244 257
         error: connectionError,
245 258
         errorMessage: connectionErrorMessage
246 259
     } = state['features/base/connection'];
247 260
 
248 261
     let error;
262
+    let errorCredentials;
249 263
     let errorDetails;
250 264
 
251 265
     if (connectionError) {
252 266
         error = connectionError;
267
+        errorCredentials = credentials;
253 268
         errorDetails = connectionErrorMessage;
254 269
     } else if (upgradeRoleError) {
255 270
         error
256 271
             = upgradeRoleError.connectionError
257 272
                 || upgradeRoleError.authenticationError;
273
+        errorCredentials = upgradeRoleError.credentials;
258 274
         errorDetails = upgradeRoleError.message;
259 275
     }
260 276
 
@@ -263,6 +279,7 @@ function _mapStateToProps(state) {
263 279
         _configHosts: configHosts,
264 280
         _connecting: Boolean(connecting) || Boolean(upgradeRoleInProgress),
265 281
         _error: error,
282
+        _errorCredentials: errorCredentials,
266 283
         _errorDetails: errorDetails
267 284
     };
268 285
 }

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

@@ -81,14 +81,18 @@ export function connect(id: ?string, password: ?string) {
81 81
          * Rejects external promise when connection fails.
82 82
          *
83 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 89
          * @returns {void}
86 90
          * @private
87 91
          */
88
-        function _onConnectionFailed(err, msg) {
92
+        function _onConnectionFailed(err, msg, credentials) {
89 93
             unsubscribe();
90 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,16 +167,21 @@ export function connectionEstablished(connection: Object) {
163 167
     };
164 168
 }
165 169
 
170
+/* eslint-disable max-params */
171
+
166 172
 /**
167 173
  * Create an action for when the signaling connection could not be created.
168 174
  *
169 175
  * @param {JitsiConnection} connection - The JitsiConnection which failed.
170 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 180
  * @public
173 181
  * @returns {{
174 182
  *     type: CONNECTION_FAILED,
175 183
  *     connection: JitsiConnection,
184
+ *     credentials: Object,
176 185
  *     error: string,
177 186
  *     message: string
178 187
  * }}
@@ -180,15 +189,19 @@ export function connectionEstablished(connection: Object) {
180 189
 export function connectionFailed(
181 190
         connection: Object,
182 191
         error: string,
183
-        message: ?string) {
192
+        message: ?string,
193
+        credentials: ?Object) {
184 194
     return {
185 195
         type: CONNECTION_FAILED,
186 196
         connection,
197
+        credentials,
187 198
         error,
188 199
         message
189 200
     };
190 201
 }
191 202
 
203
+/* eslint-enable max-params */
204
+
192 205
 /**
193 206
  * Constructs options to be passed to the constructor of {@code JitsiConnection}
194 207
  * based on the redux state.

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

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

Loading…
Cancel
Save