From 56f9b77707191cbb009e0eadd0322eaf66dcb3f4 Mon Sep 17 00:00:00 2001
From: Thilo Wischmeyer <thwischm@gmail.com>
Date: Mon, 31 May 2021 12:39:02 +0200
Subject: [PATCH] Added password validation error messages to registration
 dialog

---
 frontend/src/components/RegisterDialog.vue | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/frontend/src/components/RegisterDialog.vue b/frontend/src/components/RegisterDialog.vue
index 2f95c2d8..75f212dc 100644
--- a/frontend/src/components/RegisterDialog.vue
+++ b/frontend/src/components/RegisterDialog.vue
@@ -55,6 +55,8 @@
           required
           :rules="[ required ]"
           type="password"
+          :error-messages="passwordErrors"
+          @input="passwordErrors = null"
         />
         <v-text-field
           id="input-register-password-repeat"
@@ -105,10 +107,11 @@ export default {
       loading: false,
       acceptedGDPR: false,
       registrationFormIsValid: false,
-      required: required,
+      required,
       checkPasswordsMatch: v => v === this.credentials.password || 'Passwords do not match.',
       errorAlert: null,
       usernameErrors: null,
+      passwordErrors: null,
     }
   },
   watch: {
@@ -129,13 +132,13 @@ export default {
       registerTutor(this.credentials).then(() => {
         this.$emit('registered', this.credentials)
       }).catch(error => {
-        if (error.response && error.response.data && error.response.data.username)
-          this.usernameErrors = error.response.data.username
-        else
+        this.usernameErrors = error.response && error.response.data && error.response.data.username
+        this.passwordErrors = error.response && error.response.data && error.response.data.password
+        if (!this.usernameErrors && !this.passwordErrors)
           this.errorAlert = `Couldn't register a tutor account: ${error}`
       }).finally(() => { this.loading = false })
     }
-  }
+  },
 }
 </script>
 
-- 
GitLab