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

feat(createAccount): better error messages/handling on username error #3505

Merged
merged 2 commits into from
Jun 9, 2022
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
5 changes: 4 additions & 1 deletion components/views/friends/quick/Quick.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default Vue.extend({
return
}
if (this.isInvalidName) {
this.error = this.$t('errors.chat.group_name') as string
this.error = this.$t('errors.chat.group_name', {
min: this.$Config.chat.groupNameMinLength,
max: this.$Config.chat.groupNameMaxLength,
}) as string
return
}
// create group
Expand Down
5 changes: 4 additions & 1 deletion components/views/user/create/Create.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/>
<div v-if="showCropper" class="cropper-mask" />
<div class="modal-body">
<form @submit="confirm">
<form @submit="confirm" novalidate>
<div class="custom-modal-content">
<div class="columns">
<div class="column image">
Expand Down Expand Up @@ -50,6 +50,9 @@
v-model="name"
input-kind="text"
type="primary"
:minLength="$Config.account.minLength"
:maxLength="$Config.account.maxLength"
:invalid="isInvalidName && Boolean(error)"
/>
</div>

Expand Down
23 changes: 13 additions & 10 deletions components/views/user/create/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default Vue.extend({
data() {
return {
showCropper: false,
creating: '',
croppedImage: '',
imageUrl: '',
name: '',
Expand All @@ -33,11 +32,12 @@ export default Vue.extend({
* @description If the account isn't the length specified in the config, this returns False, true if correct length
* @example this.accountValidLength
*/
accountValidLength(): boolean {
if (this.name.trim().length < this.$Config.account.minimumAccountLength) {
return false
}
return true
isInvalidName(): boolean {
return (
!this.name ||
this.name.trim().length < this.$Config.account.minLength ||
this.name.trim().length > this.$Config.account.maxLength
)
},
/**
* @method acceptableImageFormats
Expand Down Expand Up @@ -171,11 +171,14 @@ export default Vue.extend({
confirm(e: Event) {
e.preventDefault()
if (this.isLoading) {
return false
return
}
if (!this.accountValidLength) {
this.error = this.$t('user.registration.username_error') as string
return false
if (this.isInvalidName) {
this.error = this.$t('user.registration.username_error', {
min: this.$Config.account.minLength,
max: this.$Config.account.maxLength,
}) as string
return
}
this.error = ''

Expand Down
3 changes: 2 additions & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export const Config = {
groupNameMaxLength: 64,
},
account: {
minimumAccountLength: 5,
minLength: 5,
maxLength: 32,
},
profile: {
noteMaxChars: 256,
Expand Down
6 changes: 4 additions & 2 deletions locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ export default {
empty_message_error:
'Message must contain at least one non-space character',
failed_load: 'Image failed to load',
group_name: 'Enter a group name of at least 3 characters, up to 64',
group_name:
'Enter a group name of at least {min} characters, up to {max}',
},
textile: {
friend_not_found: 'Friend not found',
Expand Down Expand Up @@ -656,7 +657,8 @@ export default {
'Customize how the world sees you, choose something memorable.',
username: 'Username',
username_placeholder: 'Neil Spaceman...',
username_error: 'Username must be at least 5 characters.',
username_error:
'Enter a username of at least {min} characters, up to {max}',
status: 'Status',
status_placeholder: 'Ready for launch...',
reg_status: {
Expand Down