Skip to content

Commit

Permalink
shifted captcha validation to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Sep 6, 2024
1 parent 098f787 commit 1b0804a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions ayushma/serializers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ class Meta:
model = User
fields = ("username", "full_name", "password", "email", "recaptcha")

def validate_recaptcha(self, value):
if not validatecaptcha(value):
def create(self, validated_data):
recaptcha = validated_data.pop("recaptcha", None)
if not validatecaptcha(recaptcha):
raise serializers.ValidationError("Invalid captcha")
return value

def validate(self, validated_data):
validated_data.pop("recaptcha", None)
return validated_data

def create(self, validated_data):
validated_data["password"] = make_password(validated_data["password"])
return super().create(validated_data)

Expand Down

0 comments on commit 1b0804a

Please sign in to comment.