Tolerate validating submitted email if 2+ users

Addresses #783
This commit is contained in:
Adarnof 2017-04-10 14:27:17 -04:00 committed by GitHub
parent 806962cda5
commit bb3e7a0449

View File

@ -30,12 +30,8 @@ class RegistrationForm(forms.Form):
if ' ' in self.cleaned_data['username']: if ' ' in self.cleaned_data['username']:
raise forms.ValidationError('Username cannot contain a space') raise forms.ValidationError('Username cannot contain a space')
# We attempt to get the user object if we succeed we know email as been used if User.objects.filter(email=self.cleaned_data['email']).count() >= 1:
try:
User.objects.get(email=self.cleaned_data['email'])
raise forms.ValidationError('Email as already been used') raise forms.ValidationError('Email as already been used')
except User.DoesNotExist:
pass
if not re.match("^\w+$", self.cleaned_data['username']): if not re.match("^\w+$", self.cleaned_data['username']):
raise forms.ValidationError('Username contains illegal characters') raise forms.ValidationError('Username contains illegal characters')