fix fields registration
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user