Beispiel #1
0
 def clean_password(self):
     password = self.cleaned_data.get('password')
     if len(password) < self.MIN_LENGTH:
         raise forms.ValidationError("The password must be at least %d characters long." % self.MIN_LENGTH)
     else:
         print '>>> password is :', password
     return password
Beispiel #2
0
 def clean(self):
     if "password" in self.cleaned_data and "password_confirm" in self.cleaned_data:
         if self.cleaned_data["password"] != self.cleaned_data[
                 "password_confirm"]:
             raise forms.ValidationError(
                 _("You must type the same password each time."))
     return self.cleaned_data
Beispiel #3
0
 def clean_email(self):
     value = self.cleaned_data["email"]
     qs = EmailAddress.objects.filter(email__iexact=value)
     if not qs.exists() or not settings.ACCOUNT_EMAIL_UNIQUE:
         return value
     raise forms.ValidationError(
         _("A user is registered with this email address."))
Beispiel #4
0
    def clean_code(self):
        code = self.cleaned_data['code']

        if not bool(match_token(self.request.user, code)):
            raise forms.ValidationError(_("The 2FA code is invalid"))

        return code
Beispiel #5
0
    def clean_advisor(self):
        advisor = self.cleaned_data['advisor']

        if len(advisor) > 0:
            if not Users.objects.filter(username=advisor, is_active=True, graduations__type=Graduations._advisor).exists():
                raise forms.ValidationError(_("Advisor doesn't exists"))

        return
Beispiel #6
0
    def clean_confirm_email(self):
        email = self.cleaned_data.get('email')
        confirm_email = self.cleaned_data.get('confirm_email')

        if not email == confirm_email:
            raise forms.ValidationError(_("The e-mails aren't equal"))

        return confirm_email
Beispiel #7
0
 def clean(self, *args, **kwargs):
     cleaned_data = super(userLoginForm, self).clean(*args, **kwargs)
     if self._errors:
         return
     user = auth.authenticate(**self.user_credentials())
     if user:
         self.user = user
     else:
         raise forms.ValidationError(
             _("Please make sure you are providing valid Phone Number and password."))
     return cleaned_data
Beispiel #8
0
 def clean_password(self):
     password = self.cleaned_data['password']
     if not self.user.check_password(password):
         raise forms.ValidationError(_("Wrong password informed"))
     return password