fix(comments): validator for emails, remove prefixes, allow length 1

This commit is contained in:
Sabe Jones
2018-10-26 16:25:15 -05:00
parent 8b81e38538
commit 5299c8d406
5 changed files with 19 additions and 34 deletions

View File

@@ -82,6 +82,7 @@
import hello from 'hellojs';
import { setUpAxios } from 'client/libs/auth';
import debounce from 'lodash/debounce';
import validator from 'validator';
import facebookSquareIcon from 'assets/svg/facebook-square.svg';
import googleIcon from 'assets/svg/google.svg';
@@ -115,13 +116,13 @@ export default {
computed: {
emailValid () {
if (this.email.length <= 3) return false;
return this.validateEmail(this.email);
return validator.isEmail(this.email);
},
emailInvalid () {
return !this.emailValid;
},
usernameValid () {
if (this.username.length <= 3) return false;
if (this.username.length < 1) return false;
return this.usernameIssues.length === 0;
},
usernameInvalid () {
@@ -143,7 +144,7 @@ export default {
methods: {
// eslint-disable-next-line func-names
validateUsername: debounce(function (username) {
if (username.length <= 3) {
if (username.length < 1) {
return;
}
this.$store.dispatch('auth:verifyUsername', {
@@ -156,10 +157,6 @@ export default {
}
});
}, 500),
validateEmail (email) {
let re = /^(([^<>()\[\]\\.,;:\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 re.test(email);
},
// @TODO: Abstract hello in to action or lib
async socialAuth (network) {
try {