Commit c0605b02f10f37fab3bbc2ed5ab6ed2cbbf2c96b
Committed by
Sergio Oliveira
1 parent
e4fe56f6
Exists in
master
and in
39 other branches
Validated if email is changed through other means
Email must not be changed through any means in the Register process Signed-off-by: Carlos Oliveira <carlospecter@gmail.com> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
colab/accounts/auth.py
colab/accounts/forms.py
... | ... | @@ -55,6 +55,19 @@ class UserCreationForm(UserForm): |
55 | 55 | widget=forms.TextInput(attrs={'readonly': 'readonly'}) |
56 | 56 | ) |
57 | 57 | |
58 | + def __init__(self, *args, **kwargs): | |
59 | + self.original_email = kwargs.pop('email', None) | |
60 | + super(UserCreationForm, self).__init__(*args, **kwargs) | |
61 | + | |
62 | + def clean_email(self): | |
63 | + form_email = self.cleaned_data['email'] | |
64 | + | |
65 | + if form_email != self.original_email: | |
66 | + raise forms.ValidationError('This is not the original email.') | |
67 | + | |
68 | + return form_email | |
69 | + | |
70 | + | |
58 | 71 | def clean_username(self): |
59 | 72 | username = self.cleaned_data['username'] |
60 | 73 | username = username.strip() | ... | ... |