fix fields registration
This commit is contained in:
@@ -169,13 +169,20 @@ const messages = {
|
||||
email: 'inserire una email valida',
|
||||
errore_generico: 'Si prega di compilare correttamente i campi',
|
||||
atleast: 'dev\'essere lungo almeno di',
|
||||
complexity: 'deve contenere almeno 1 carattere minuscolo, 1 maiuscola e 1 cifra',
|
||||
complexity: 'deve contenere almeno 1 minuscola, 1 maiuscola e 1 cifra',
|
||||
notmore: 'non dev\'essere lungo più di',
|
||||
char: 'caratteri',
|
||||
terms: 'Devi accettare le condizioni, per continuare.',
|
||||
duplicate_email: 'l\'Email è già stata registrata',
|
||||
duplicate_username: 'L\'Username è stato già utilizzato',
|
||||
sameaspassword: 'Le password devono essere identiche',
|
||||
},
|
||||
tips: {
|
||||
email: 'inserisci la tua email',
|
||||
username: 'username lunga almeno 6 caratteri',
|
||||
password: 'deve contenere 1 minuscola, 1 maiuscola e 1 cifra',
|
||||
repeatpassword: 'ripetere la password',
|
||||
|
||||
}
|
||||
},
|
||||
login: {
|
||||
|
||||
@@ -9,12 +9,11 @@
|
||||
|
||||
<!--Prova URL : {{env('PROVA_PAOLO')}}-->
|
||||
<form>
|
||||
<div class="q-gutter-md">
|
||||
<div class="q-gutter-xs">
|
||||
|
||||
<q-input
|
||||
v-model="signin.username"
|
||||
rounded outlined
|
||||
autocomplete="username"
|
||||
@blur="$v.signin.username.$touch"
|
||||
:error="$v.signin.username.$error"
|
||||
:error-message="`${errorMsg('username', $v.signin.username)}`"
|
||||
|
||||
@@ -14,37 +14,36 @@ import { Logo } from '../../../components/logo'
|
||||
|
||||
@Component({
|
||||
mixins: [validationMixin],
|
||||
validations: validations,
|
||||
validations,
|
||||
components: { Logo }
|
||||
})
|
||||
|
||||
export default class Signup extends Vue {
|
||||
public $v
|
||||
public $q
|
||||
$t: any
|
||||
public $t: any
|
||||
|
||||
duplicate_email: boolean = false
|
||||
duplicate_username: boolean = false
|
||||
public duplicate_email: boolean = false
|
||||
public duplicate_username: boolean = false
|
||||
|
||||
public signup: ISignupOptions = {
|
||||
email: process.env.TEST_EMAIL,
|
||||
email: process.env.TEST_EMAIL || '',
|
||||
username: process.env.TEST_USERNAME || '',
|
||||
password: process.env.TEST_PASSWORD,
|
||||
repeatPassword: process.env.TEST_PASSWORD,
|
||||
terms: true
|
||||
password: process.env.TEST_PASSWORD || '',
|
||||
repeatPassword: process.env.TEST_PASSWORD || '',
|
||||
terms: process.env.PROD ? false : true
|
||||
}
|
||||
|
||||
|
||||
created() {
|
||||
public created() {
|
||||
this.$v.$reset()
|
||||
}
|
||||
|
||||
mounted() {
|
||||
public mounted() {
|
||||
}
|
||||
|
||||
get allowSubmit() {
|
||||
|
||||
let error = this.$v.$error || this.$v.$invalid
|
||||
const error = this.$v.$error || this.$v.$invalid
|
||||
return !error
|
||||
}
|
||||
|
||||
@@ -90,8 +89,8 @@ export default class Signup extends Vue {
|
||||
|
||||
public errorMsg(cosa: string, item: any) {
|
||||
try {
|
||||
if (!item.$error) return ''
|
||||
if (item.$params.email && !item.email) return this.$t('reg.err.email')
|
||||
if (!item.$error) { return '' }
|
||||
if (item.$params.email && !item.email) { return this.$t('reg.err.email') }
|
||||
|
||||
if (cosa === 'repeatpassword') {
|
||||
if (!item.sameAsPassword) {
|
||||
@@ -99,26 +98,26 @@ export default class Signup extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
if (!item.required) return this.$t('reg.err.required')
|
||||
if (!item.required) { return this.$t('reg.err.required') }
|
||||
if (cosa === 'email') {
|
||||
// console.log("EMAIL " + item.isUnique);
|
||||
// console.log(item);
|
||||
if (!item.isUnique) return this.$t('reg.err.duplicate_email')
|
||||
if (!item.isUnique) { return this.$t('reg.err.duplicate_email') }
|
||||
} else if (cosa === 'username') {
|
||||
// console.log(item);
|
||||
if (!item.isUnique) return this.$t('reg.err.duplicate_username')
|
||||
if (!item.isUnique) { return this.$t('reg.err.duplicate_username') }
|
||||
}
|
||||
|
||||
if (!item.complexity) return this.$t('reg.err.complexity')
|
||||
if (!item.minLength) return this.$t('reg.err.atleast') + ` ${item.$params.minLength.min} ` + this.$t('reg.err.char')
|
||||
if (!item.maxLength) return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char')
|
||||
if (!item.complexity) { return this.$t('reg.err.complexity') }
|
||||
if (!item.minLength) { return this.$t('reg.err.atleast') + ` ${item.$params.minLength.min} ` + this.$t('reg.err.char') }
|
||||
if (!item.maxLength) { return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char') }
|
||||
return ''
|
||||
} catch (error) {
|
||||
// console.log("ERR : " + error);
|
||||
}
|
||||
}
|
||||
|
||||
checkErrors(riscode: number) {
|
||||
public checkErrors(riscode: number) {
|
||||
console.log('checkErrors', riscode)
|
||||
if (riscode === tools.DUPLICATE_EMAIL_ID) {
|
||||
tools.showNotif(this.$q, this.$t('reg.err.duplicate_email'))
|
||||
@@ -127,7 +126,7 @@ export default class Signup extends Vue {
|
||||
} else if (riscode === tools.ERR_SERVERFETCH) {
|
||||
tools.showNotif(this.$q, this.$t('fetch.errore_server'))
|
||||
} else if (riscode === tools.ERR_GENERICO) {
|
||||
let msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
|
||||
const msg = this.$t('fetch.errore_generico') + UserStore.mutations.getMsgError(riscode)
|
||||
tools.showNotif(this.$q, msg)
|
||||
} else if (riscode === tools.OK) {
|
||||
this.$router.push('/signin')
|
||||
@@ -136,8 +135,6 @@ export default class Signup extends Vue {
|
||||
tools.showNotif(this.$q, 'Errore num ' + riscode)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public submitOk() {
|
||||
@@ -163,7 +160,7 @@ export default class Signup extends Vue {
|
||||
.then((riscode) => {
|
||||
this.checkErrors(riscode)
|
||||
this.$q.loading.hide()
|
||||
}).catch(error => {
|
||||
}).catch((error) => {
|
||||
console.log('ERROR = ' + error)
|
||||
this.$q.loading.hide()
|
||||
})
|
||||
@@ -171,4 +168,3 @@ export default class Signup extends Vue {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,81 +8,88 @@
|
||||
|
||||
<!--Prova URL : {{env('PROVA_PAOLO')}}-->
|
||||
|
||||
<q-field
|
||||
:error="$v.signup.email.$error"
|
||||
:error-label="`${errorMsg('email', $v.signup.email)}`"
|
||||
>
|
||||
<div class="q-gutter-xs">
|
||||
<q-input
|
||||
v-model="signup.email"
|
||||
@change="val => { signup.email = val }"
|
||||
:before="[{icon: 'mail', handler () {}}]"
|
||||
rounded outlined
|
||||
@blur="$v.signup.email.$touch"
|
||||
:error="$v.signup.email.$error"
|
||||
:float-label="$t('reg.email')"></q-input>
|
||||
</q-field>
|
||||
:error-message="errorMsg('email', $v.signup.email)"
|
||||
bottom-slots
|
||||
:label="$t('reg.email')">
|
||||
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="email"/>
|
||||
</template>
|
||||
|
||||
</q-input>
|
||||
|
||||
<q-field
|
||||
:error="$v.signup.username.$error"
|
||||
:error-label="`${errorMsg('username', $v.signup.username)}`"
|
||||
>
|
||||
<q-input
|
||||
v-model="signup.username"
|
||||
@change="val => { signup.username = val }"
|
||||
:before="[{icon: 'person', handler () {}}]"
|
||||
rounded outlined
|
||||
@blur="$v.signup.username.$touch"
|
||||
:error="$v.signup.username.$error"
|
||||
:float-label="$t('reg.username')"></q-input>
|
||||
</q-field>
|
||||
bottom-slots
|
||||
:error-message="errorMsg('username', $v.signup.username)"
|
||||
:label="$t('reg.username')">
|
||||
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="person"/>
|
||||
</template>
|
||||
|
||||
</q-input>
|
||||
|
||||
<q-field
|
||||
:error="$v.signup.password.$error"
|
||||
:error-label="`${errorMsg('password', $v.signup.password)}`"
|
||||
>
|
||||
<q-input
|
||||
v-model="signup.password"
|
||||
type="password"
|
||||
:before="[{icon: 'vpn_key', handler () {}}]"
|
||||
rounded outlined
|
||||
@blur="$v.signup.password.$touch"
|
||||
:error="$v.signup.password.$error"
|
||||
:float-label="$t('reg.password')"></q-input>
|
||||
</q-field>
|
||||
:error-message="`${errorMsg('password', $v.signup.password)}`"
|
||||
bottom-slots
|
||||
:label="$t('reg.password')">
|
||||
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="vpn_key"/>
|
||||
</template>
|
||||
|
||||
</q-input>
|
||||
|
||||
<q-field
|
||||
:error="$v.signup.repeatPassword.$error"
|
||||
:error-label="`${errorMsg('repeatpassword', $v.signup.repeatPassword)}`"
|
||||
>
|
||||
<q-input
|
||||
v-model="signup.repeatPassword"
|
||||
type="password"
|
||||
:before="[{icon: 'vpn_key', handler () {}}]"
|
||||
rounded outlined
|
||||
@blur="$v.signup.repeatPassword.$touch"
|
||||
:error="$v.signup.repeatPassword.$error"
|
||||
:float-label="$t('reg.repeatPassword')"></q-input>
|
||||
</q-field>
|
||||
:error-message="`${errorMsg('repeatpassword', $v.signup.repeatPassword)}`"
|
||||
bottom-slots
|
||||
:label="$t('reg.repeatPassword')">
|
||||
|
||||
<q-field
|
||||
:error="$v.signup.terms.$error"
|
||||
:error-label="`${errorMsg('terms', $v.signup.terms)}`"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="vpn_key"/>
|
||||
</template>
|
||||
|
||||
</q-input>
|
||||
|
||||
<!--:hint="$t('reg.tips.repeatpassword')"-->
|
||||
|
||||
<q-checkbox
|
||||
v-model="signup.terms"
|
||||
:before="[{icon: 'vpn_key', handler () {}}]"
|
||||
color="secondary"
|
||||
@blur="$v.signup.terms.$touch"
|
||||
:error="$v.signup.terms.$error"
|
||||
:float-label="$t('reg.terms')"
|
||||
:label="$t('reg.terms')"></q-checkbox>
|
||||
</q-field>
|
||||
:error-message="`${errorMsg('terms', $v.signup.terms)}`"
|
||||
:label="$t('reg.terms')">
|
||||
|
||||
</q-checkbox>
|
||||
<br>
|
||||
|
||||
<div class="wrapper">
|
||||
<q-btn rounded size="lg" color="positive" @click="submitOk" :disabled='!allowSubmit'>{{$t('reg.submit')}}
|
||||
<q-btn rounded size="lg" color="positive" @click="submitOk" :disabled='!allowSubmit'>
|
||||
{{$t('reg.submit')}}
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user