summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-04-04 09:10:05 +0200
committerGitHub <noreply@github.com>2023-04-04 09:10:05 +0200
commit0395b796e20cda04a749410c5157e338d357cd99 (patch)
treee6c713ea18e9b3b797502c6217defe09a20afec4 /apps
parent0dbc7a8f3a2be40369557bdc375172b5c8c5d38f (diff)
parent82bbcca720de26f453aa5aaf26ff28920e57f59d (diff)
downloadnextcloud-server-0395b796e20cda04a749410c5157e338d357cd99.tar.gz
nextcloud-server-0395b796e20cda04a749410c5157e338d357cd99.zip
Merge pull request #37523 from nextcloud/backport/37497/stable26
[stable26] Improve handling of profile fields
Diffstat (limited to 'apps')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php2
-rw-r--r--apps/settings/src/components/PersonalInfo/EmailSection/Email.vue6
-rw-r--r--apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue6
-rw-r--r--apps/settings/src/components/PersonalInfo/LanguageSection/Language.vue7
-rw-r--r--apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue6
-rw-r--r--apps/settings/src/components/PersonalInfo/ProfileSection/ProfileCheckbox.vue6
-rw-r--r--apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/VisibilityDropdown.vue6
-rw-r--r--apps/settings/src/components/PersonalInfo/shared/AccountPropertySection.vue6
-rw-r--r--apps/settings/src/components/PersonalInfo/shared/FederationControl.vue6
-rw-r--r--apps/settings/src/utils/handlers.js48
10 files changed, 66 insertions, 33 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 1613561fbe1..6a7bf668129 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -634,6 +634,7 @@ class UsersController extends AUserData {
* @NoAdminRequired
* @NoSubAdminRequired
* @PasswordConfirmationRequired
+ * @UserRateThrottle(limit=5, period=60)
*
* @throws OCSException
*/
@@ -726,6 +727,7 @@ class UsersController extends AUserData {
* @NoAdminRequired
* @NoSubAdminRequired
* @PasswordConfirmationRequired
+ * @UserRateThrottle(limit=50, period=600)
*
* edit users
*
diff --git a/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue b/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue
index c6c4376fa10..717f5a322f9 100644
--- a/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue
+++ b/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue
@@ -90,11 +90,10 @@ import { NcActions, NcActionButton } from '@nextcloud/vue'
import AlertCircle from 'vue-material-design-icons/AlertCircleOutline.vue'
import AlertOctagon from 'vue-material-design-icons/AlertOctagon.vue'
import Check from 'vue-material-design-icons/Check'
-import { showError } from '@nextcloud/dialogs'
import debounce from 'debounce'
import FederationControl from '../shared/FederationControl.vue'
-import logger from '../../../logger.js'
+import { handleError } from '../../../utils/handlers.js'
import { ACCOUNT_PROPERTY_READABLE_ENUM, VERIFICATION_ENUM } from '../../../constants/AccountPropertyConstants.js'
import {
@@ -358,8 +357,7 @@ export default {
this.showCheckmarkIcon = true
setTimeout(() => { this.showCheckmarkIcon = false }, 2000)
} else {
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
this.showErrorIcon = true
setTimeout(() => { this.showErrorIcon = false }, 2000)
}
diff --git a/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue b/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue
index 6bfb8bfee8b..613b90356c3 100644
--- a/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue
+++ b/apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue
@@ -63,7 +63,6 @@
<script>
import { loadState } from '@nextcloud/initial-state'
-import { showError } from '@nextcloud/dialogs'
import Email from './Email.vue'
import HeaderBar from '../shared/HeaderBar.vue'
@@ -71,7 +70,7 @@ import HeaderBar from '../shared/HeaderBar.vue'
import { ACCOUNT_PROPERTY_READABLE_ENUM, DEFAULT_ADDITIONAL_EMAIL_SCOPE, NAME_READABLE_ENUM } from '../../../constants/AccountPropertyConstants.js'
import { savePrimaryEmail, savePrimaryEmailScope, removeAdditionalEmail } from '../../../service/PersonalInfo/EmailService.js'
import { validateEmail } from '../../../utils/validate.js'
-import logger from '../../../logger.js'
+import { handleError } from '../../../utils/handlers.js'
const { emailMap: { additionalEmails, primaryEmail, notificationEmail } } = loadState('settings', 'personalInfoParameters', {})
const { displayNameChangeSupported } = loadState('settings', 'accountParameters', {})
@@ -186,8 +185,7 @@ export default {
handleResponse(status, errorMessage, error) {
if (status !== 'ok') {
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
}
},
diff --git a/apps/settings/src/components/PersonalInfo/LanguageSection/Language.vue b/apps/settings/src/components/PersonalInfo/LanguageSection/Language.vue
index adff44b2565..959e7153e17 100644
--- a/apps/settings/src/components/PersonalInfo/LanguageSection/Language.vue
+++ b/apps/settings/src/components/PersonalInfo/LanguageSection/Language.vue
@@ -51,12 +51,10 @@
</template>
<script>
-import { showError } from '@nextcloud/dialogs'
-
import { ACCOUNT_SETTING_PROPERTY_ENUM } from '../../../constants/AccountPropertyConstants.js'
import { savePrimaryAccountProperty } from '../../../service/PersonalInfo/PersonalInfoService.js'
import { validateLanguage } from '../../../utils/validate.js'
-import logger from '../../../logger.js'
+import { handleError } from '../../../utils/handlers.js'
export default {
name: 'Language',
@@ -133,8 +131,7 @@ export default {
// Ensure that local state reflects server state
this.initialLanguage = language
} else {
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
}
},
diff --git a/apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue b/apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue
index 025938c4149..0b7c7c9d616 100644
--- a/apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue
+++ b/apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue
@@ -58,14 +58,13 @@
</template>
<script>
-import { showError } from '@nextcloud/dialogs'
import moment from '@nextcloud/moment'
import Web from 'vue-material-design-icons/Web'
import { ACCOUNT_SETTING_PROPERTY_ENUM } from '../../../constants/AccountPropertyConstants.js'
import { savePrimaryAccountProperty } from '../../../service/PersonalInfo/PersonalInfoService.js'
import { validateLocale } from '../../../utils/validate.js'
-import logger from '../../../logger.js'
+import { handleError } from '../../../utils/handlers.js'
export default {
name: 'Locale',
@@ -155,8 +154,7 @@ export default {
this.initialLocale = locale
} else {
this.$emit('update:locale', this.initialLocale)
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
}
},
diff --git a/apps/settings/src/components/PersonalInfo/ProfileSection/ProfileCheckbox.vue b/apps/settings/src/components/PersonalInfo/ProfileSection/ProfileCheckbox.vue
index 433daa0ca89..b8e8d6301d3 100644
--- a/apps/settings/src/components/PersonalInfo/ProfileSection/ProfileCheckbox.vue
+++ b/apps/settings/src/components/PersonalInfo/ProfileSection/ProfileCheckbox.vue
@@ -32,13 +32,12 @@
</template>
<script>
-import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { savePrimaryAccountProperty } from '../../../service/PersonalInfo/PersonalInfoService.js'
import { ACCOUNT_PROPERTY_ENUM } from '../../../constants/AccountPropertyConstants.js'
-import logger from '../../../logger.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
+import { handleError } from '../../../utils/handlers.js'
export default {
name: 'ProfileCheckbox',
@@ -82,8 +81,7 @@ export default {
if (status === 'ok') {
emit('settings:profile-enabled:updated', isProfileEnabled)
} else {
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
}
this.loading = false
},
diff --git a/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/VisibilityDropdown.vue b/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/VisibilityDropdown.vue
index f00130ec0a4..91c4dfffc0c 100644
--- a/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/VisibilityDropdown.vue
+++ b/apps/settings/src/components/PersonalInfo/ProfileVisibilitySection/VisibilityDropdown.vue
@@ -36,7 +36,6 @@
</template>
<script>
-import { showError } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
@@ -44,7 +43,7 @@ import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import { saveProfileParameterVisibility } from '../../../service/ProfileService.js'
import { VISIBILITY_PROPERTY_ENUM } from '../../../constants/ProfileConstants.js'
-import logger from '../../../logger.js'
+import { handleError } from '../../../utils/handlers.js'
const { profileEnabled } = loadState('settings', 'personalInfoParameters', false)
@@ -136,8 +135,7 @@ export default {
// Ensure that local state reflects server state
this.initialVisibility = visibility
} else {
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
}
},
diff --git a/apps/settings/src/components/PersonalInfo/shared/AccountPropertySection.vue b/apps/settings/src/components/PersonalInfo/shared/AccountPropertySection.vue
index c80d1a36658..1d20f900e26 100644
--- a/apps/settings/src/components/PersonalInfo/shared/AccountPropertySection.vue
+++ b/apps/settings/src/components/PersonalInfo/shared/AccountPropertySection.vue
@@ -71,7 +71,6 @@
<script>
import debounce from 'debounce'
-import { showError } from '@nextcloud/dialogs'
import AlertCircle from 'vue-material-design-icons/AlertCircleOutline.vue'
import AlertOctagon from 'vue-material-design-icons/AlertOctagon'
@@ -80,7 +79,7 @@ import Check from 'vue-material-design-icons/Check'
import HeaderBar from '../shared/HeaderBar.vue'
import { savePrimaryAccountProperty } from '../../../service/PersonalInfo/PersonalInfoService.js'
-import logger from '../../../logger.js'
+import { handleError } from '../../../utils/handlers.js'
export default {
name: 'AccountPropertySection',
@@ -196,8 +195,7 @@ export default {
setTimeout(() => { this.showCheckmarkIcon = false }, 2000)
} else {
this.$emit('update:value', this.initialValue)
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
this.showErrorIcon = true
setTimeout(() => { this.showErrorIcon = false }, 2000)
}
diff --git a/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue b/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue
index ae1392fe580..2a6356e38c0 100644
--- a/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue
+++ b/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue
@@ -42,7 +42,6 @@
<script>
import NcActions from '@nextcloud/vue/dist/Components/NcActions'
import { loadState } from '@nextcloud/initial-state'
-import { showError } from '@nextcloud/dialogs'
import FederationControlAction from './FederationControlAction.vue'
@@ -56,7 +55,7 @@ import {
UNPUBLISHED_READABLE_PROPERTIES,
} from '../../../constants/AccountPropertyConstants.js'
import { savePrimaryAccountPropertyScope } from '../../../service/PersonalInfo/PersonalInfoService.js'
-import logger from '../../../logger.js'
+import { handleError } from '../../../utils/handlers.js'
const {
federationEnabled,
@@ -188,8 +187,7 @@ export default {
this.initialScope = scope
} else {
this.$emit('update:scope', this.initialScope)
- showError(errorMessage)
- logger.error(errorMessage, error)
+ handleError(error, errorMessage)
}
},
},
diff --git a/apps/settings/src/utils/handlers.js b/apps/settings/src/utils/handlers.js
new file mode 100644
index 00000000000..59f55d172f4
--- /dev/null
+++ b/apps/settings/src/utils/handlers.js
@@ -0,0 +1,48 @@
+/**
+ * @copyright 2023 Christopher Ng <chrng8@gmail.com>
+ *
+ * @author Christopher Ng <chrng8@gmail.com>
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+import { showError } from '@nextcloud/dialogs'
+import { translate as t } from '@nextcloud/l10n'
+
+import logger from '../logger.js'
+
+/**
+ * @param {import('axios').AxiosError} error the error
+ * @param {string?} message the message to display
+ */
+export const handleError = (error, message) => {
+ let fullMessage = ''
+
+ if (message) {
+ fullMessage += message
+ }
+
+ if (error.response?.status === 429) {
+ if (fullMessage) {
+ fullMessage += '\n'
+ }
+ fullMessage += t('settings', 'There were too many requests from your network. Retry later or contact your administrator if this is an error.')
+ }
+
+ showError(fullMessage)
+ logger.error(fullMessage || t('Error'), error)
+}