Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add generic invalid token error code
Aleksander Spyra0674d22a0b3d
diff --git a/saleor/graphql/account/mutations/account.py b/saleor/graphql/account/mutations/account.pyindex 111074358b..5c0eabf4f4 100644--- a/saleor/graphql/account/mutations/account.py+++ b/saleor/graphql/account/mutations/account.py@@ -8,7 +8,7 @@ from ....core.utils.url import validate_storefront_urlfrom ...account.enums import AddressTypeEnumfrom ...account.types import Address, AddressInput, Userfrom ...core.mutations import BaseMutation, ModelDeleteMutation, ModelMutation-from ...core.utils.error_codes import AccountErrorCode+from ...core.utils.error_codes import AccountErrorCode, CommonErrorCodefrom .base import (INVALID_TOKEN,BaseAddressDelete,@@ -140,7 +140,7 @@ class AccountDelete(ModelDeleteMutation):raise ValidationError({"token": ValidationError(- INVALID_TOKEN, code=AccountErrorCode.INVALID_USER_TOKEN+ INVALID_TOKEN, code=CommonErrorCode.INVALID_TOKEN)})diff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.pyindex 964e46ee59..9370ab32bf 100644--- a/saleor/graphql/account/mutations/base.py+++ b/saleor/graphql/account/mutations/base.py@@ -83,7 +83,7 @@ class SetPassword(CreateToken):raise ValidationError({"token": ValidationError(- INVALID_TOKEN, code=AccountErrorCode.INVALID_USER_TOKEN+ INVALID_TOKEN, code=CommonErrorCode.INVALID_TOKEN)})diff --git a/saleor/graphql/core/utils/error_codes.py b/saleor/graphql/core/utils/error_codes.pyindex 21177a650e..f939b8c86a 100644--- a/saleor/graphql/core/utils/error_codes.py+++ b/saleor/graphql/core/utils/error_codes.py@@ -50,7 +50,6 @@ class AccountErrorCode(Enum):INVALID_COUNTRY = "invalid_country"INVALID_PASSWORD = "invalid_password"INVALID_PHONE_NUMBER = "invalid_phone_number"- INVALID_USER_TOKEN = "invalid_user_token"NOT_USERS_ADDRESS = "not_users_address"@@ -99,6 +98,7 @@ class CommonErrorCode(Enum):INCORRECT_VALUE = "incorrect_value"INVALID_FILE_TYPE = "invalid_file_type"INVALID_STOREFRONT_URL = "invalid_storefront_url"+ INVALID_TOKEN = "invalid_token"INVALID_WEIGHT_UNIT = "invalid_weight_unit"MISSING_VALUE = "missing_value"NON_BLANK_VALUE_REQUIRED = "non_blank_value_required"diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex ac9ffa5c9d..f69585a553 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -1434,7 +1434,7 @@ enum ErrorCode {INVALID_SHIPPING_METHODINVALID_STOREFRONT_URLINVALID_TIME- INVALID_USER_TOKEN+ INVALID_TOKENINVALID_WEIGHT_UNITLIMIT_VALUEMAX_DECIMAL_PLACESdiff --git a/tests/api/test_account.py b/tests/api/test_account.pyindex 0e15b6bc62..4b4414e6b4 100644--- a/tests/api/test_account.py+++ b/tests/api/test_account.py@@ -26,7 +26,7 @@ from saleor.graphql.account.mutations.staff import ()from saleor.graphql.core.enums import PermissionEnumfrom saleor.graphql.core.utils import str_to_enum-from saleor.graphql.core.utils.error_codes import AccountErrorCode, CommonErrorCode+from saleor.graphql.core.utils.error_codes import CommonErrorCodefrom saleor.order.models import FulfillmentStatus, Orderfrom tests.api.utils import get_graphql_contentfrom tests.utils import create_image@@ -1646,7 +1646,7 @@ def test_set_password_invalid_token(user_api_client, customer_user):content = get_graphql_content(response)errors = content["data"]["setPassword"]["errors"]assert errors[0]["message"] == INVALID_TOKEN- assert errors[0]["code"] == AccountErrorCode.INVALID_USER_TOKEN.name+ assert errors[0]["code"] == CommonErrorCode.INVALID_TOKEN.namedef test_set_password_invalid_email(user_api_client):