From 9808e1c4f860dbd829ef0ea782a48ff033727dfd Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 24 Sep 2019 23:59:08 +0200 Subject: [PATCH] Validate different email address --- webapp/locales/de.json | 3 +++ webapp/locales/en.json | 3 +++ .../pages/settings/my-email-address/index.vue | 21 ++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/webapp/locales/de.json b/webapp/locales/de.json index ad85d045f..04fa5d0b6 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -159,6 +159,9 @@ "success": "Deine Daten wurden erfolgreich aktualisiert!" }, "email": { + "validation": { + "same-email": "Muss sich unterscheiden von der jetzigen E-Mail Addresse" + }, "name": "Deine E-Mail", "labelEmail": "E-Mail Adresse ändern", "labelNewEmail": "Neue E-Mail Adresse", diff --git a/webapp/locales/en.json b/webapp/locales/en.json index ce6cae5ed..cabfa1b06 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -160,6 +160,9 @@ "success": "Your data was successfully updated!" }, "email": { + "validation": { + "same-email": "Must be different from your current E-Mail address" + }, "name": "Your E-Mail", "labelEmail": "Change your E-Mail address", "labelNewEmail": "New E-Mail Address", diff --git a/webapp/pages/settings/my-email-address/index.vue b/webapp/pages/settings/my-email-address/index.vue index 510a9d7e5..a166d5521 100644 --- a/webapp/pages/settings/my-email-address/index.vue +++ b/webapp/pages/settings/my-email-address/index.vue @@ -32,9 +32,6 @@ export default { data() { return { success: false, - formSchema: { - email: { type: 'email', required: true }, - }, } }, computed: { @@ -54,6 +51,24 @@ export default { this.formData = formData }, }, + formSchema() { + const { email } = this.currentUser + const sameEmailValidationError = this.$t('settings.email.validation.same-email') + return { + email: [ + { type: 'email', required: true }, + { + validator(rule, value, callback, source, options) { + const errors = [] + if (email === value) { + errors.push(sameEmailValidationError) + } + return errors + }, + }, + ], + } + }, }, methods: { async submit() {