Skip to content

Commit

Permalink
WIP: Limit email input on auth pages to 255 chars
Browse files Browse the repository at this point in the history
Excessively long emails reported to make server unresponsive.

NOTE : Would could consider adding a configuration for sysadmins to bypass this setting
on their instance if they want.

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Mar 15, 2024
1 parent eb61f6b commit 4f9dee4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/components/login/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

Expand Down Expand Up @@ -117,8 +120,11 @@ import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'

import LoginButton from './LoginButton.vue'

import AuthMixin from '../../mixins/auth.js'

export default {
name: 'LoginForm',
mixins: [AuthMixin],

components: {
LoginButton,
Expand Down
6 changes: 6 additions & 0 deletions core/src/components/login/ResetPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
<NcTextField id="user"
:value.sync="user"
name="user"
:maxlength="255"
autocapitalize="off"
:label="t('core', 'Login or email')"
:error="userNameInputLengthIs255"
:helper-text="userInputHelperText"
required
@change="updateUsername" />
<LoginButton :value="t('core', 'Reset password')" />
Expand Down Expand Up @@ -60,8 +63,11 @@ import LoginButton from './LoginButton.vue'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'

import AuthMixin from '../../mixins/auth.js'

export default {
name: 'ResetPassword',
mixins: [AuthMixin],
components: {
LoginButton,
NcNoteCard,
Expand Down
36 changes: 36 additions & 0 deletions core/src/mixins/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @copyright Copyright (c) 2024 Fon E. Noel NFEBE <opensource@nfebe.com>
*
* @author Fon E. Noel NFEBE <opensource@nfebe.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/>.
*
*/

export default {

computed: {
userNameInputLengthIs255() {

Check failure on line 26 in core/src/mixins/auth.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 8 spaces
return this.user.length >= 255

Check failure on line 27 in core/src/mixins/auth.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 3 tabs but found 12 spaces
},

Check failure on line 28 in core/src/mixins/auth.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 8 spaces
userInputHelperText() {

Check failure on line 29 in core/src/mixins/auth.js

View workflow job for this annotation

GitHub Actions / NPM lint

Expected indentation of 2 tabs but found 8 spaces
if (this.emailLength === 255) {
return t('core', 'Email length is at max (255)')
}
return undefined
},
},
}

0 comments on commit 4f9dee4

Please sign in to comment.