From 15115a4353a2a4b5ac727a68f82d8042fb9264f9 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Fri, 15 Mar 2024 11:46:19 +0100 Subject: feat: Limit email input on auth pages to 255 chars Excessively long emails reported make server unresponsive. We could at some point, consider adding a configuration for sysadmins to bypass this setting on their instance if they want. Signed-off-by: fenn-cs --- core/src/components/login/LoginForm.vue | 8 ++++++- core/src/components/login/ResetPassword.vue | 4 ++++ core/src/mixins/auth.js | 36 +++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 core/src/mixins/auth.js (limited to 'core/src') diff --git a/core/src/components/login/LoginForm.vue b/core/src/components/login/LoginForm.vue index 417c0d67819..c4750d28da4 100644 --- a/core/src/components/login/LoginForm.vue +++ b/core/src/components/login/LoginForm.vue @@ -62,12 +62,15 @@ ref="user" :label="loginText" name="user" + :maxlength="255" :value.sync="user" :class="{shake: invalidPassword}" autocapitalize="none" :spellchecking="false" :autocomplete="autoCompleteAllowed ? 'username' : 'off'" required + :error="userNameInputLengthIs255" + :helper-text="userInputHelperText" data-login-form-input-user @change="updateUsername" /> @@ -117,6 +120,8 @@ import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js' import LoginButton from './LoginButton.vue' +import AuthMixin from '../../mixins/auth.js' + export default { name: 'LoginForm', @@ -126,6 +131,7 @@ export default { NcTextField, NcNoteCard, }, + mixins: [AuthMixin], props: { username: { @@ -160,7 +166,7 @@ export default { type: Array, default() { return [] - } + }, }, }, diff --git a/core/src/components/login/ResetPassword.vue b/core/src/components/login/ResetPassword.vue index e1d66daa4aa..7059484f1d1 100644 --- a/core/src/components/login/ResetPassword.vue +++ b/core/src/components/login/ResetPassword.vue @@ -25,6 +25,7 @@ + * + * @author Fon E. Noel NFEBE + * + * @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 . + * + */ + +export default { + + computed: { + userNameInputLengthIs255() { + return this.user.length >= 255 + }, + userInputHelperText() { + if (this.userNameInputLengthIs255) { + return t('core', 'Email length is at max (255)') + } + return undefined + }, + }, +} -- cgit v1.2.3