diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index e874a1aa5985d..95414c0eaea8c 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -606,6 +606,7 @@ public function getEditableFieldsForUser(string $userId): DataResponse { * @NoAdminRequired * @NoSubAdminRequired * @PasswordConfirmationRequired + * @UserRateThrottle(limit=5, period=60) * * @throws OCSException */ @@ -698,6 +699,7 @@ public function editUserMultiValue( * @NoAdminRequired * @NoSubAdminRequired * @PasswordConfirmationRequired + * @UserRateThrottle(limit=50, period=600) * * edit users * diff --git a/apps/settings/js/federationsettingsview.js b/apps/settings/js/federationsettingsview.js index c91d34530c1e7..a0748b5598caf 100644 --- a/apps/settings/js/federationsettingsview.js +++ b/apps/settings/js/federationsettingsview.js @@ -164,6 +164,10 @@ } else { self._showInputChangeFail(field); } + }).fail(function(data) { + if (data.status === 429) { + OC.Notification.showTemporary(t('settings', 'There were too many requests from your network. Retry later or contact your administrator if this is an error.')) + } }); }, @@ -181,7 +185,12 @@ $('#' + field + 'scope').val(scope); // TODO: user loading/success feedback - this._config.save(); + var savingData = this._config.save(); + $.when(savingData).fail(function(data) { + if (data.status === 429) { + OC.Notification.showTemporary(t('settings', 'There were too many requests from your network. Retry later or contact your administrator if this is an error.')) + } + }); this._setFieldScopeIcon(field, scope); this._updateVerifyButton(field, scope); }, diff --git a/apps/settings/js/settings/personalInfo.js b/apps/settings/js/settings/personalInfo.js index 7a7788ec64895..e9b909828bfb1 100644 --- a/apps/settings/js/settings/personalInfo.js +++ b/apps/settings/js/settings/personalInfo.js @@ -248,6 +248,8 @@ window.addEventListener('DOMContentLoaded', function () { var selectedLocale = $("#localeinput").val(), user = OC.getCurrentUser(); + var errorMessage = t('settings', 'An error occurred while changing your locale. Please reload the page and try again.') + $.ajax({ url: OC.linkToOCS('cloud/users', 2) + user['uid'], method: 'PUT', @@ -259,8 +261,14 @@ window.addEventListener('DOMContentLoaded', function () { moment.locale(selectedLocale); }, fail: function() { - OC.Notification.showTemporary(t('settings', 'An error occurred while changing your locale. Please reload the page and try again.')); - } + OC.Notification.showTemporary(errorMessage); + }, + error: function(xhr) { + if (xhr.status === 429) { + errorMessage += '\n' + t('settings', 'There were too many requests from your network. Retry later or contact your administrator if this is an error.') + } + OC.Notification.showTemporary(errorMessage) + }, }); }; $("#localeinput").change(updateLocale); diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 6be93d6a3a03d..7a1a457f4c686 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -344,6 +344,7 @@ protected function canAdminChangeUserPasswords(): bool { * @NoAdminRequired * @NoSubAdminRequired * @PasswordConfirmationRequired + * @UserRateThrottle(limit=50, period=600) * * @param string|null $avatarScope * @param string|null $displayname diff --git a/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue b/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue index 38c3bd3b89023..3cbe4bf9bf684 100644 --- a/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue +++ b/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue @@ -79,12 +79,12 @@