Commit c0605b02f10f37fab3bbc2ed5ab6ed2cbbf2c96b

Authored by Carlos Coêlho
Committed by Sergio Oliveira
1 parent e4fe56f6

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
... ... @@ -14,7 +14,7 @@ class ColabBrowserIDBackend(BrowserIDBackend):
14 14  
15 15 user = self.User.objects.filter(emails__address=email)
16 16  
17   - if not user:
  17 + if user:
18 18 return user
19 19  
20 20 return self.User.objects.create_user(
... ...
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()
... ...