From 1da9d430a51de78f88793b1f017d135649a43441 Mon Sep 17 00:00:00 2001 From: ogerly Date: Sat, 10 Apr 2021 17:51:19 +0200 Subject: [PATCH] fix register --- frontend/src/locales/de.json | 11 +- frontend/src/locales/en.json | 9 +- frontend/src/views/Pages/Register.vue | 159 ++++++++++++++++++++------ 3 files changed, 136 insertions(+), 43 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 3b9d2e217..8f6975889 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -24,7 +24,7 @@ "sender":"Absender", "firstname":"Vorname", "lastname":"Nachname", - "email":"eMail", + "email":"E-Mail", "email_repeat":"eMail wiederholen", "password":"Passwort", "password_repeat":"Passwort wiederholen", @@ -59,9 +59,12 @@ "signup": { "title": "Erstelle dein Gradido-Konto", "subtitle": "Werde Teil der Gemeinschaft!", - "strength":"Passwortsicherheit:", - "strong":"stark", - "agree":"habe ich gelesen und verstanden und stimme diesen zu." + "agree":"Ich stimme der Datenschutzerklärung zu.", + "lowercase":"Ein Kleinbuchstabe erforderlich.", + "uppercase":"Ein Großbuchstabe erforderlich.", + "minimum":"Mindestens 8 Zeichen.", + "one_number":"Eine Zahl erforderlich.", + "dont_match":"Die Passwörter stimmen nicht überein." }, "password": { "title": "Passwort zurücksetzen", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index d05a9e0d5..849873cae 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -59,9 +59,12 @@ "signup": { "title": "Create your Gradido account", "subtitle": "Become a part of the community!", - "strength":"Password strength:", - "strong":"strong", - "agree":"I have read and understood and agree to them" + "agree":"I agree to the privacy policy.", + "lowercase":"One lowercase letter required.", + "uppercase":"One uppercase letter required.", + "minimum":"8 characters minimum.", + "one_number":"One number required.", + "dont_match":"Passwords don't match." }, "password": { "title": "Reset password", diff --git a/frontend/src/views/Pages/Register.vue b/frontend/src/views/Pages/Register.vue index d207404d2..addafca1d 100755 --- a/frontend/src/views/Pages/Register.vue +++ b/frontend/src/views/Pages/Register.vue @@ -26,52 +26,79 @@ +
+ + + + + + + + + + + + -
- - {{ $t('site.signup.strength') }} - - {{ $t('site.signup.strong') }} - - -
+ :placeholder="$t('form.password_repeat')" + prepend-icon="ni ni-lock-circle-open" + v-model.lazy="checkPassword" + :class="{ valid: passwordValidation.valid }" + /> + + +
+
    +
  • + {{ error }} +
  • +
+
+
+

+ {{ $t('site.signup.dont_match') }} + +

+
+
+ - - - {{ $t('privacy_policy') }} - - - {{ $t('site.signup.agree') }} - + -
+
{{ $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 } + } + }, + }, }