示例#1
0
    def clean_email(self):
        try:
            user = User.objects.get(email=self.cleaned_data["email"])
        except User.DoesNotExist:
            raise forms.ValidationError(m.email_not_registered)

        verify_account(user)

        # Required to let the save method in AuthPasswordResetForm work
        self.users_cache = [user]
        return self.cleaned_data["email"]
示例#2
0
文件: forms.py 项目: Dpetters/Umeqo
    def clean_email(self):
        try:
            user = User.objects.get(email = self.cleaned_data["email"])
        except User.DoesNotExist:
            raise forms.ValidationError(m.email_not_registered)

        verify_account(user)

        # Required to let the save method in AuthPasswordResetForm work
        self.users_cache = [user]
        return self.cleaned_data["email"]
示例#3
0
文件: forms.py 项目: Dpetters/Umeqo
 def clean(self):
     username = self.cleaned_data.get('username')
     password = self.cleaned_data.get('password')
     if username and password:
         try:
             user = User.objects.get(email=username)
             username = user.username
         except User.DoesNotExist:
             pass
         self.user_cache = authenticate(username=username, password=password)
         if self.user_cache is None:
             raise forms.ValidationError(m.incorrect_username_password_combo)
         
         verify_account(self.user_cache)
         
         if not self.user_cache.is_active:
             self.user_cache.is_active = True
             self.user_cache.save()
     self.check_for_test_cookie()
     return self.cleaned_data
示例#4
0
    def clean(self):
        username = self.cleaned_data.get('username')
        password = self.cleaned_data.get('password')
        if username and password:
            try:
                user = User.objects.get(email=username)
                username = user.username
            except User.DoesNotExist:
                pass
            self.user_cache = authenticate(username=username,
                                           password=password)
            if self.user_cache is None:
                raise forms.ValidationError(
                    m.incorrect_username_password_combo)

            verify_account(self.user_cache)

            if not self.user_cache.is_active:
                self.user_cache.is_active = True
                self.user_cache.save()
        self.check_for_test_cookie()
        return self.cleaned_data