From e10908ea1377e6297baa2d5e72f12c9d037a239b Mon Sep 17 00:00:00 2001 From: Roman Bauernfeind <6105226+RomanBf@users.noreply.github.com> Date: Sun, 20 May 2018 18:12:14 +0200 Subject: [PATCH] Add check for special error from meteor/ddp-rate-limiter Fixes [this issue](https://github.com/meteor-useraccounts/core/issues/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). --- lib/client/client.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/client/client.js b/lib/client/client.js index e1c0cd0..429424a 100644 --- a/lib/client/client.js +++ b/lib/client/client.js @@ -182,10 +182,14 @@ AccountsTemplates.submitCallback = function(error, state, onSuccess) { AccountsTemplates.state.form.set('error', errorsWithoutField); } } else { - // If error.details is an object, we may try to set fields errors from it - _.each(error.details, function(error, fieldId) { - AccountsTemplates.getField(fieldId).setError(error); - }); + if (error.error == 'too-many-requests') { + AccountsTemplates.state.form.set('error', [error.reason]); + } else { + // If error.details is an object, we may try to set fields errors from it + _.each(error.details, function (error, fieldId) { + AccountsTemplates.getField(fieldId).setError(error); + }); + } } } else { var err = 'error.accounts.Unknown error';