Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Code reformat, schema update

Tomasz Szymański2cf07ee33203
diff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.py
index cfce2775f5..88bde3484d 100644
--- a/saleor/graphql/account/mutations/base.py
+++ b/saleor/graphql/account/mutations/base.py
@@ -160,7 +160,7 @@ class ConfirmAccount(BaseMutation):
)
email = graphene.String(
description="E-mail of the user performing account confirmation.",
- required=True
+ required=True,
)
class Meta:
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 7f3ce8cee7..b61f97ffb0 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1027,6 +1027,10 @@ enum ConfigurationTypeFieldEnum {
PASSWORD
}
+type ConfirmAccount {
+ errors: [Error!]
+}
+
enum CountryCode {
AF
AX
@@ -2259,6 +2263,7 @@ type Mutation {
checkoutUpdatePrivateMetadata(id: ID!, input: MetaInput!): CheckoutUpdatePrivateMeta
checkoutClearPrivateMetadata(id: ID!, input: MetaPath!): CheckoutClearPrivateMeta
requestPasswordReset(email: String!, redirectUrl: String!): RequestPasswordReset
+ confirmAccount(email: String!, token: String!): ConfirmAccount
setPassword(token: String!, email: String!, password: String!): SetPassword
passwordChange(newPassword: String!, oldPassword: String!): PasswordChange
accountAddressCreate(input: AddressInput!, type: AddressTypeEnum): AccountAddressCreate
diff --git a/saleor/settings.py b/saleor/settings.py
index 0fa9ecc970..1378a0135c 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -128,7 +128,10 @@ EMAIL_BACKEND = email_config["EMAIL_BACKEND"]
EMAIL_USE_TLS = email_config["EMAIL_USE_TLS"]
EMAIL_USE_SSL = email_config["EMAIL_USE_SSL"]
-ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL = True
+# WARNING: frontend confirmation screen is NOT created yet.
+# Enabling this feature will cause incomplete registrations.
+# Should remain disabled unless you know what you're doing!
+ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL = False
ENABLE_SSL = get_bool_from_env("ENABLE_SSL", False)
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index ec042c5e70..3ffce41c51 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -579,6 +579,7 @@ ACCOUNT_REGISTER_MUTATION = """
"""
+@override_settings(ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL=True)
@patch("saleor.account.emails._send_account_confirmation_email")
def test_customer_register(send_account_confirmation_email_mock, user_api_client):
@@ -606,7 +607,9 @@ def test_customer_register(send_account_confirmation_email_mock, user_api_client
@override_settings(ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL=False)
@patch("saleor.account.emails._send_account_confirmation_email")
-def test_customer_register_disabled_email_confirmation(send_account_confirmation_email_mock, user_api_client):
+def test_customer_register_disabled_email_confirmation(
+ send_account_confirmation_email_mock, user_api_client
+):
variables = {"email": "[email protected]", "password": "Password"}
user_api_client.post_graphql(ACCOUNT_REGISTER_MUTATION, variables)
assert send_account_confirmation_email_mock.delay.call_count == 0
@@ -2144,38 +2147,33 @@ def test_account_confirmation(user_api_client, customer_user):
variables = {
"email": customer_user.email,
- "token": default_token_generator.make_token(customer_user)
+ "token": default_token_generator.make_token(customer_user),
}
user_api_client.post_graphql(CONFIRM_ACCOUNT_MUTATION, variables)
customer_user.refresh_from_db()
- assert customer_user.is_active == True
+ assert customer_user.is_active is True
def test_account_confirmation_invalid_user(user_api_client, customer_user):
variables = {
"email": "[email protected]",
- "token": default_token_generator.make_token(customer_user)
+ "token": default_token_generator.make_token(customer_user),
}
response = user_api_client.post_graphql(CONFIRM_ACCOUNT_MUTATION, variables)
content = get_graphql_content(response)
- assert content["data"]["confirmAccount"]["errors"] == [{
- "field": "email",
- "message": "User with this email doesn't exist"
- }]
+ assert content["data"]["confirmAccount"]["errors"] == [
+ {"field": "email", "message": "User with this email doesn't exist"}
+ ]
def test_account_confirmation_invalid_token(user_api_client, customer_user):
- variables = {
- "email": customer_user.email,
- "token": "invalid_token"
- }
+ variables = {"email": customer_user.email, "token": "invalid_token"}
response = user_api_client.post_graphql(CONFIRM_ACCOUNT_MUTATION, variables)
content = get_graphql_content(response)
- assert content["data"]["confirmAccount"]["errors"] == [{
- "field": "token",
- "message": "Invalid or expired token."
- }]
+ assert content["data"]["confirmAccount"]["errors"] == [
+ {"field": "token", "message": "Invalid or expired token."}
+ ]
@patch("saleor.account.emails._send_password_reset_email")