From d8dde92c864749d1455aaff67f8f79d4dcd2ee02 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Dec 2018 16:13:33 +0100 Subject: [PATCH 1/3] Fix user registration and validation --- js/src/components/Account/Register.vue | 32 ++++++++++++-------------- js/src/components/Account/Validate.vue | 30 ++++++++++++------------ js/src/graphql/user.ts | 11 ++------- lib/mobilizon/actors/actors.ex | 8 ++++++- 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/js/src/components/Account/Register.vue b/js/src/components/Account/Register.vue index d3010c55c..7108b9484 100644 --- a/js/src/components/Account/Register.vue +++ b/js/src/components/Account/Register.vue @@ -121,12 +121,9 @@ }, }; rules = { - password_length: value => value.length > 6 || 'Password must be at least 6 caracters long', + password_length: value => value.length > 6 || 'Password must be at least 6 characters long', required: value => !!value || 'Required.', - email: (value) => { - const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - return pattern.test(value) || 'Invalid e-mail.'; - }, + email: (value: string) => value.indexOf('@') !== -1 || 'Invalid e-mail.', }; resetState() { @@ -154,20 +151,21 @@ return this.rules.email(this.email) === true ? 'v-gravatar' : 'avatar'; } - submit() { - this.$apollo.mutate({ - mutation: CREATE_USER, - variables: { - email: this.email, - password: this.password, - username: this.username, - }, - }).then((data) => { - console.log(data); + async submit() { + try { + await this.$apollo.mutate({ + mutation: CREATE_USER, + variables: { + email: this.email, + password: this.password, + username: this.username, + }, + }); + this.validationSent = true; - }).catch((error) => { + } catch (error) { console.error(error); - }); + } } }; diff --git a/js/src/components/Account/Validate.vue b/js/src/components/Account/Validate.vue index 32815d7f5..a9d2a1f72 100644 --- a/js/src/components/Account/Validate.vue +++ b/js/src/components/Account/Validate.vue @@ -19,7 +19,7 @@