Skip to content

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

Fix rewiev remark

fowczarek91c6e02bc139
diff --git a/saleor/account/emails.py b/saleor/account/emails.py
index cd7f2e51ff..69dd29f17c 100644
--- a/saleor/account/emails.py
+++ b/saleor/account/emails.py
@@ -11,14 +11,19 @@ from ..core.emails import get_email_base_context
from ..core.utils import build_absolute_uri
-def send_user_password_reset_email(redirect_url, user):
+def send_user_password_reset_email_with_url(redirect_url, user):
"""Trigger sending a password reset email for the given user."""
token = default_token_generator.make_token(user)
- send_password_reset_email_with_url.delay(user.email, redirect_url, user.pk, token)
+ _send_password_reset_email_with_url.delay(user.email, redirect_url, user.pk, token)
+
+
+def send_user_password_reset_email(recipient_email, context, user_id):
+ """Trigger sending a password reset email for the given user."""
+ _send_user_password_reset_email.delay(recipient_email, context, user_id)
@app.task
-def send_password_reset_email(recipient_email, context, user_id):
+def _send_user_password_reset_email(recipient_email, context, user_id):
reset_url = build_absolute_uri(
reverse(
"account:reset-password-confirm",
@@ -29,7 +34,7 @@ def send_password_reset_email(recipient_email, context, user_id):
@app.task
-def send_password_reset_email_with_url(recipient_email, redirect_url, user_id, token):
+def _send_password_reset_email_with_url(recipient_email, redirect_url, user_id, token):
params = urlencode({"email": recipient_email, "token": token})
reset_url = "%(redirect_url)s?%(params)s" % {
"redirect_url": redirect_url,
diff --git a/saleor/account/forms.py b/saleor/account/forms.py
index ab2273152d..cde19f0d4e 100644
--- a/saleor/account/forms.py
+++ b/saleor/account/forms.py
@@ -135,7 +135,7 @@ class PasswordResetForm(django_forms.PasswordResetForm, FormWithReCaptcha):
# error "'User' is not JSON serializable". Since it's not used in our
# template, we remove it from the context.
user = context.pop("user")
- emails.send_password_reset_email.delay(to_email, context, user.pk)
+ emails.send_user_password_reset_email(to_email, context, user.pk)
class NameForm(forms.ModelForm):
diff --git a/saleor/graphql/account/mutations/base.py b/saleor/graphql/account/mutations/base.py
index 6d8f6145e7..b51fd43bfd 100644
--- a/saleor/graphql/account/mutations/base.py
+++ b/saleor/graphql/account/mutations/base.py
@@ -6,7 +6,7 @@ from django.db import transaction
from graphql_jwt.exceptions import PermissionDenied
from ....account import events as account_events, models
-from ....account.emails import send_user_password_reset_email
+from ....account.emails import send_user_password_reset_email_with_url
from ....core.utils.url import validate_storefront_url
from ....dashboard.emails import send_set_password_customer_email
from ...account.i18n import I18nMixin
@@ -110,7 +110,7 @@ class RequestPasswordReset(BaseMutation):
user = models.User.objects.get(email=email)
except ObjectDoesNotExist:
raise ValidationError({"email": "User with this email doesn't exist"})
- send_user_password_reset_email(redirect_url, user)
+ send_user_password_reset_email_with_url(redirect_url, user)
return RequestPasswordReset()
diff --git a/saleor/graphql/account/mutations/deprecated_staff.py b/saleor/graphql/account/mutations/deprecated_staff.py
index 46dd46a097..6083c8c5b8 100644
--- a/saleor/graphql/account/mutations/deprecated_staff.py
+++ b/saleor/graphql/account/mutations/deprecated_staff.py
@@ -18,7 +18,7 @@ def send_user_password_reset_email(user, site):
"domain": site.domain,
"protocol": "https" if settings.ENABLE_SSL else "http",
}
- emails.send_password_reset_email.delay(user.email, context, user.pk)
+ emails.send_user_password_reset_email(user.email, context, user.pk)
class PasswordReset(BaseMutation):
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index 09404c3b44..4435c84885 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -1482,7 +1482,7 @@ def test_set_password_invalid_password(user_api_client, customer_user, settings)
assert errors[1]["message"] == "This password is entirely numeric."
-@patch("saleor.account.emails.send_password_reset_email.delay")
+@patch("saleor.account.emails._send_user_password_reset_email.delay")
def test_deprecated_password_reset_email(
send_password_reset_mock, staff_api_client, customer_user, permission_manage_users
):
@@ -1510,7 +1510,7 @@ def test_deprecated_password_reset_email(
)
-@patch("saleor.account.emails.send_password_reset_email.delay")
+@patch("saleor.account.emails._send_user_password_reset_email.delay")
def test_password_reset_email_non_existing_user(
send_password_reset_mock, staff_api_client, permission_manage_users
):