Skip to content

Commit e450808

Browse files
authored
Add check for special error from meteor/ddp-rate-limiter
Fixes [this issue](meteor-useraccounts/core#629). Without checking for this error, when rate-limiting kicks in it throws an error because `fieldId` is set to "timeToReset" (and this field does not exist). The whole accounts-form then is disabled and unresponsive, without informing the user about what's going on (you can only see the error message in the client-side browser console).
1 parent c409d14 commit e450808

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/client/client.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,14 @@ AccountsTemplates.submitCallback = function(error, state, onSuccess) {
187187
AccountsTemplates.state.form.set('error', errorsWithoutField);
188188
}
189189
} else {
190-
// If error.details is an object, we may try to set fields errors from it
191-
_.each(error.details, function(error, fieldId) {
192-
AccountsTemplates.getField(fieldId).setError(error);
193-
});
190+
if (error.error == 'too-many-requests') {
191+
AccountsTemplates.state.form.set('error', [error.reason]);
192+
} else {
193+
// If error.details is an object, we may try to set fields errors from it
194+
_.each(error.details, function (error, fieldId) {
195+
AccountsTemplates.getField(fieldId).setError(error);
196+
});
197+
}
194198
}
195199
} else {
196200
var err = 'error.accounts.Unknown error';

0 commit comments

Comments
 (0)