Esempio n. 1
0
    def clean(self):
        cleaned_data = SetPasswordForm.clean(self)
        if 'new_password1' in cleaned_data:
            if (len(cleaned_data['new_password1']) < MIN_PASSWORD_LENGTH or
               len(cleaned_data['new_password1']) > MAX_PASSWORD_LENGTH):

                self._errors['new_password1'] = ErrorList(
                  ['New password must be between %d and %d characters long.' %
                   (MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH)])
                del cleaned_data['new_password1']
                if 'new_password2' in cleaned_data:
                    del cleaned_data['new_password2']

        return cleaned_data
Esempio n. 2
0
    def clean(self):
        cleaned_data = SetPasswordForm.clean(self)
        if 'new_password1' in cleaned_data:
            if (len(cleaned_data['new_password1']) < MIN_PASSWORD_LENGTH or
               len(cleaned_data['new_password1']) > MAX_PASSWORD_LENGTH):

                self._errors['new_password1'] = ErrorList(
                  ['New password must be between %d and %d characters long.' %
                   (MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH)])
                del cleaned_data['new_password1']
                if 'new_password2' in cleaned_data:
                    del cleaned_data['new_password2']

        return cleaned_data
Esempio n. 3
0
    def clean(self):
        cleaned_data = SetPasswordForm.clean(self)
        if "new_password1" in cleaned_data:
            if (
                len(cleaned_data["new_password1"]) < MIN_PASSWORD_LENGTH
                or len(cleaned_data["new_password1"]) > MAX_PASSWORD_LENGTH
            ):

                self._errors["new_password1"] = ErrorList(
                    [
                        "New password must be between %d and %d characters long."
                        % (MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH)
                    ]
                )
                del cleaned_data["new_password1"]
                if "new_password2" in cleaned_data:
                    del cleaned_data["new_password2"]

        return cleaned_data
Esempio n. 4
0
 def clean(self):
     if self.user.username:
         self.cleaned_data["username"] = self.user.username
     else:
         self.cleaned_data["username"] = "******"
     SetPasswordForm.clean(self)