mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
Added the check for duplicate email registration
This commit is contained in:
parent
1dac6bbaa5
commit
cabd0a87f1
@ -1,4 +1,5 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
class RegistrationForm(forms.Form):
|
class RegistrationForm(forms.Form):
|
||||||
@ -12,6 +13,13 @@ class RegistrationForm(forms.Form):
|
|||||||
if ' ' in self.cleaned_data['username']:
|
if ' ' in self.cleaned_data['username']:
|
||||||
raise forms.ValidationError(u'Username can not contain a space')
|
raise forms.ValidationError(u'Username can not contain a space')
|
||||||
|
|
||||||
|
# We attempt to get the user object if we succeed we know email as been used
|
||||||
|
try:
|
||||||
|
User.objects.get(email=self.cleaned_data['email'])
|
||||||
|
raise forms.ValidationError(u'Email as already been used')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if 'password' in self.cleaned_data and 'password_again' in self.cleaned_data:
|
if 'password' in self.cleaned_data and 'password_again' in self.cleaned_data:
|
||||||
if self.cleaned_data['password'] != self.cleaned_data['password_again']:
|
if self.cleaned_data['password'] != self.cleaned_data['password_again']:
|
||||||
raise forms.ValidationError(u'Passwords do not match')
|
raise forms.ValidationError(u'Passwords do not match')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user