+
{{ $t('signup') }}
@@ -115,13 +147,32 @@ export default {
firstname: '',
lastname: '',
email: '',
- password: '',
- password2: '',
agree: false,
},
+ rules: [
+ { message: this.$t('site.signup.lowercase'), regex: /[a-z]+/ },
+ { message: this.$t('site.signup.uppercase'), regex: /[A-Z]+/ },
+ { message: this.$t('site.signup.minimum'), regex: /.{8,}/ },
+ { message: this.$t('site.signup.one_number'), regex: /[0-9]+/ },
+ ],
+ password: '',
+ checkPassword: '',
+ passwordVisible: false,
+ submitted: false,
}
},
methods: {
+ resetPasswords() {
+ this.password = ''
+ this.checkPassword = ''
+ this.submitted = true
+ setTimeout(() => {
+ this.submitted = false
+ }, 2000)
+ },
+ togglePasswordVisibility() {
+ this.passwordVisible = !this.passwordVisible
+ },
onSubmit() {
// console.log("this.modals =>", this.modals)
this.$store.dispatch('createUser', {
@@ -138,6 +189,42 @@ export default {
this.$router.push('/thx')
},
},
+ computed: {
+ notSamePasswords() {
+ if (this.passwordsFilled) {
+ return this.password !== this.checkPassword
+ } else {
+ return false
+ }
+ },
+ passwordsFilled() {
+ return this.password !== '' && this.checkPassword !== ''
+ },
+ namesFilled() {
+ return (
+ this.model.firstname !== '' &&
+ this.model.firstname.length > 2 &&
+ this.model.lastname !== '' &&
+ this.model.lastname.length > 1
+ )
+ },
+ emailFilled() {
+ return this.model.email !== ''
+ },
+ passwordValidation() {
+ let errors = []
+ for (let condition of this.rules) {
+ if (!condition.regex.test(this.password)) {
+ errors.push(condition.message)
+ }
+ }
+ if (errors.length === 0) {
+ return { valid: true, errors }
+ } else {
+ return { valid: false, errors }
+ }
+ },
+ },
}