Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] feat: Limit email input to 255 chars #45290

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,20 @@ public function tryLogin(Chain $loginChain,
);
}

$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,
Expand Down
4 changes: 4 additions & 0 deletions core/Controller/LostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public function email(string $user): JSONResponse {

$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',
Expand Down
6 changes: 6 additions & 0 deletions core/src/components/login/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

Expand Down Expand Up @@ -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',

Expand All @@ -128,6 +133,7 @@ export default {
NcTextField,
NcNoteCard,
},
mixins: [AuthMixin],

props: {
username: {
Expand Down
4 changes: 4 additions & 0 deletions core/src/components/login/ResetPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -61,13 +62,16 @@ 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: {
LoginButton,
NcNoteCard,
NcTextField,
},
mixins: [AuthMixin],
props: {
username: {
type: String,
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() {
return this.user.length >= 255
},
userInputHelperText() {
if (this.userNameInputLengthIs255) {
return t('core', 'Email length is at max (255)')
}
return undefined
},
},
}
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

Loading