Merge pull request #45290 from nextcloud/backport/44218/stable27

[stable27] feat: Limit email input to 255 chars
This commit is contained in:
Josh 2024-05-30 09:29:51 -04:00 committed by GitHub
commit 5bc8329bf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 65 additions and 4 deletions

View file

@ -316,9 +316,20 @@ class LoginController extends Controller {
);
}
$user = trim($user);
if (strlen($user) > 255) {
return $this->createLoginFailedResponse(
$user,
$user,
$redirect_url,
$this->l10n->t('Unsupported email length (>255)')
);
}
$data = new LoginData(
$this->request,
trim($user),
$user,
$password,
$redirect_url,
$timezone,

View file

@ -202,6 +202,10 @@ class LostController extends Controller {
$user = trim($user);
if (strlen($user) > 255) {
return new JSONResponse($this->error($this->l10n->t('Unsupported email length (>255)')));
}
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',

View file

@ -63,12 +63,15 @@
:label="t('core', 'Account name or email')"
:label-visible="true"
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" />
@ -119,6 +122,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',
@ -128,6 +133,7 @@ export default {
NcTextField,
NcNoteCard,
},
mixins: [AuthMixin],
props: {
username: {

View file

@ -25,6 +25,7 @@
<NcTextField id="user"
:value.sync="user"
name="user"
:maxlength="255"
autocapitalize="off"
:label="t('core', 'Account name or email')"
:label-visible="true"
@ -61,6 +62,8 @@ 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',
components: {
@ -68,6 +71,7 @@ export default {
NcNoteCard,
NcTextField,
},
mixins: [AuthMixin],
props: {
username: {
type: String,

36
core/src/mixins/auth.js Normal file
View file

@ -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() {
return this.user.length >= 255
},
userInputHelperText() {
if (this.userNameInputLengthIs255) {
return t('core', 'Email length is at max (255)')
}
return undefined
},
},
}

4
dist/core-login.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long