Commit c988cf2c41ad57211ac4f945efe5028dc1d56115
Committed by
Sergio Oliveira
1 parent
ab94e3df
Exists in
master
and in
4 other branches
Changed error message for already registered email.
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> Signed-off-by: Lucas Moura <lucas.moura128@gmail.com>
Showing
1 changed file
with
13 additions
and
0 deletions
Show diff stats
colab/accounts/forms.py
... | ... | @@ -12,6 +12,9 @@ from django.utils.encoding import force_bytes |
12 | 12 | from django.utils.http import urlsafe_base64_encode |
13 | 13 | from django.utils.text import capfirst |
14 | 14 | from django.utils.translation import ugettext_lazy as _ |
15 | +from django.core.validators import validate_email | |
16 | +from django.core.exceptions import ValidationError | |
17 | +from django.utils.safestring import mark_safe | |
15 | 18 | |
16 | 19 | from conversejs.models import XMPPAccount |
17 | 20 | |
... | ... | @@ -59,6 +62,16 @@ class UserForm(forms.ModelForm): |
59 | 62 | if field_name in UserForm.required: |
60 | 63 | field.required = True |
61 | 64 | |
65 | + def clean_email(self): | |
66 | + email = self.cleaned_data.get('email') | |
67 | + username = self.cleaned_data.get('username') | |
68 | + | |
69 | + if email and User.objects.filter(email=email).exclude( | |
70 | + username=username).count(): | |
71 | + raise forms.ValidationError( | |
72 | + mark_safe("Try login in: <a href='login'>sign in<a/>")) | |
73 | + return email | |
74 | + | |
62 | 75 | def clean_username(self): |
63 | 76 | username = self.cleaned_data["username"].strip() |
64 | 77 | if not username: | ... | ... |