Exemple #1
0
    def clean(self):
        cleaned_data = super(ChangePasswordForm, self).clean()

        password_old = cleaned_data.get('password_old')

        # Check if the actual password is not empty
        if password_old:
            user_exist = authenticate(username=self.user.username, password=password_old)
            # Check if the user exist with old informations.
            if not user_exist and password_old != '':
                self._errors['password_old'] = self.error_class([_(u'Mot de passe incorrect.')])
                if 'password_old' in cleaned_data:
                    del cleaned_data['password_old']

        return validate_passwords(cleaned_data, password_label='password_new', username=self.user.username)
Exemple #2
0
    def clean(self):
        cleaned_data = super().clean()

        password_old = cleaned_data.get("password_old")

        # Check if the actual password is not empty
        if password_old:
            user_exist = authenticate(username=self.user.username,
                                      password=password_old)
            # Check if the user exist with old informations.
            if not user_exist and password_old != "":
                self._errors["password_old"] = self.error_class(
                    [_("Mot de passe incorrect.")])
                if "password_old" in cleaned_data:
                    del cleaned_data["password_old"]

        return validate_passwords(cleaned_data,
                                  password_label="password_new",
                                  username=self.user.username)
Exemple #3
0
 def clean(self):
     cleaned_data = super(NewPasswordForm, self).clean()
     return validate_passwords(cleaned_data, username=self.username)
Exemple #4
0
 def clean(self):
     cleaned_data = super(RegisterForm, self).clean()
     return validate_passwords(cleaned_data)
Exemple #5
0
 def clean(self):
     validate_raw_zds_username(self.data)
     cleaned_data = super(RegisterForm, self).clean()
     return validate_passwords(cleaned_data)