diff --git a/api-collection/Auth/CreateAccount/Invalid identifier.bru b/api-collection/Auth/CreateAccount/Invalid identifier.bru index 9f3a941..f43f97c 100644 --- a/api-collection/Auth/CreateAccount/Invalid identifier.bru +++ b/api-collection/Auth/CreateAccount/Invalid identifier.bru @@ -12,9 +12,9 @@ post { body:json { { - "unique_identifiers": "' 'DROP TABLE USERS;", - "username": "My Name", - "password": "qweasd123", - "email": "myname@email.com" + "unique_identifier": "' 'DROP TABLE USERS;", + "username": " ", + "password": "wasd123", + "email": "mynameemail.com" } } diff --git a/api-collection/Auth/Mail confirmation/ConfirmAccount.bru b/api-collection/Auth/Mail confirmation/ConfirmAccount.bru index d39a126..2be10dc 100644 --- a/api-collection/Auth/Mail confirmation/ConfirmAccount.bru +++ b/api-collection/Auth/Mail confirmation/ConfirmAccount.bru @@ -5,7 +5,13 @@ meta { } post { - url: {{baseUrl}}/accounts/confirm-account/ - body: none + url: {{baseUrl}}/accounts/confirm-account + body: json auth: none } + +body:json { + { + "token": "asdasdasdasdasd" + } +} diff --git a/src/accounts/api/serializers.py b/src/accounts/api/serializers.py index 67093ce..eba6557 100644 --- a/src/accounts/api/serializers.py +++ b/src/accounts/api/serializers.py @@ -22,9 +22,12 @@ class Meta: fields = ("unique_identifier", "username", "password", "email") extra_kwargs = {"password": {"write_only": True}} - def validate_password(self, value): + def validate_password(self, value: str): # Validate the password using Django's built-in validators - temp_user = Account(**self.initial_data) + temp_user = Account( + unique_identifier=self.initial_data.get("unique_identifier"), + username=self.initial_data.get("username"), + ) validate_password(value, temp_user) return value @@ -69,9 +72,12 @@ class VerifyAccountSerializer(serializers.Serializer): class ResetPasswordSerializer(serializers.Serializer): password = serializers.CharField(style={"input_type": "password"}) - def validate_password(self, value): + def validate_password(self, value: str): # Validate the password using Django's built-in validators - temp_user = Account(**self.initial_data) + temp_user = Account( + unique_identifier=self.initial_data.get("unique_identifier"), + username=self.initial_data.get("username"), + ) validate_password(value, temp_user) return value @@ -83,10 +89,10 @@ def validate(self, data): try: account_confirmation = AccountConfirmation.objects.get(token=data["token"]) except AccountConfirmation.DoesNotExist: - raise serializers.ValidationError("Token is invalid or expired.") + raise serializers.ValidationError({"token": "Token is invalid or expired."}) if not account_confirmation.is_token_valid(): - raise serializers.ValidationError("Token is invalid or expired.") + raise serializers.ValidationError({"token": "Token is invalid or expired."}) return {"token": data["token"]}