diff --git a/colab/accounts/auth.py b/colab/accounts/auth.py index 9500fbd..4ccda35 100644 --- a/colab/accounts/auth.py +++ b/colab/accounts/auth.py @@ -14,7 +14,7 @@ class ColabBrowserIDBackend(BrowserIDBackend): user = self.User.objects.filter(emails__address=email) - if not user: + if user: return user return self.User.objects.create_user( diff --git a/colab/accounts/forms.py b/colab/accounts/forms.py index fcb6a75..c871a94 100644 --- a/colab/accounts/forms.py +++ b/colab/accounts/forms.py @@ -55,6 +55,19 @@ class UserCreationForm(UserForm): widget=forms.TextInput(attrs={'readonly': 'readonly'}) ) + def __init__(self, *args, **kwargs): + self.original_email = kwargs.pop('email', None) + super(UserCreationForm, self).__init__(*args, **kwargs) + + def clean_email(self): + form_email = self.cleaned_data['email'] + + if form_email != self.original_email: + raise forms.ValidationError('This is not the original email.') + + return form_email + + def clean_username(self): username = self.cleaned_data['username'] username = username.strip() -- libgit2 0.21.2