def validate_password(form, field): user = UserModel().get_by_username(form.username.data) if user is None: raise ValidationError("auth error") entry_password = get_password_hash(settings.SECRET_KEY, user.username, field.data) if entry_password != user.password: raise ValidationError("auth error") form.user = user
def set_password(self, password): self.password = get_password_hash(SECRET_KEY, self.username, password)