Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Pacu24f645afa415e
diff --git a/docs/architecture/gdpr.rst b/docs/architecture/gdpr.rstindex 95a04902ae..93471a6717 100644--- a/docs/architecture/gdpr.rst+++ b/docs/architecture/gdpr.rst@@ -9,7 +9,7 @@ Deleting usersA user account can be deleted from the dashboard, by a staff user.This action takes place immediately.-From the storefront, user can request his account deletion+From the storefront, a user can request his account deletionfrom within his profile settings, in such case, a confirmation email will besent to the email address associated with the account.@@ -23,14 +23,6 @@ CookiesAll cookies used by Saleor are functional, therefore there's no need to notifythe users about them.-Profiling------------Saleor comes with optional integration with Google Analytics, users data is-anonymized, however, if you decide to use it,-you should be mentioned in your privacy policy.--Manual actions required=======================@@ -38,5 +30,5 @@ Privacy Policy and Terms of Service-----------------------------------Make sure your Terms of Service or Privacy Policy properly communicate to your-users how you are using their data.+users who you are and how you are using their data.We recommend you ensure your policies are up to date and clear to your readers.diff --git a/saleor/account/emails.py b/saleor/account/emails.pyindex d9fa6e1a83..e5646793f8 100644--- a/saleor/account/emails.py+++ b/saleor/account/emails.py@@ -1,5 +1,6 @@from celery import shared_taskfrom django.conf import settings+from django.contrib.sites.models import Sitefrom django.urls import reversefrom templated_email import send_templated_mail@@ -21,16 +22,13 @@ def send_password_reset_email(context, recipient):@shared_task-def send_account_delete_confirmation_email(context=None, recipient=None):- # TODO - FIXME- # reset_url = build_absolute_uri(- # reverse(- # 'account:account-delete-confirm',- # kwargs={'token': context['token']}))- # context['delete_url'] = reset_url- # send_templated_mail(- # template_name='account/password_reset',- # from_email=settings.DEFAULT_FROM_EMAIL,- # recipient_list=[recipient],- # context=context)- pass+def send_account_delete_confirmation_email(token, recipient_email):+ site = Site.objects.get_current()+ delete_url = build_absolute_uri(+ reverse('account:delete-confirm', kwargs={'token': token}))+ ctx = {'site_name': site.name, 'domain': site.domain, 'url': delete_url}+ send_templated_mail(+ template_name='account/account_delete',+ from_email=settings.DEFAULT_FROM_EMAIL,+ recipient_list=[recipient_email],+ context=ctx)diff --git a/saleor/account/views.py b/saleor/account/views.pyindex a029683f9a..e4bc1fc1f6 100755--- a/saleor/account/views.py+++ b/saleor/account/views.py@@ -131,10 +131,11 @@ def address_delete(request, pk):@require_POSTdef account_delete(request, pk):user = get_object_or_404(User, pk=pk)+ import pdb; pdb.set_trace()+if request.user.pk != user.pk:raise Http404('No such page!')-- send_account_delete_confirmation_email.delay(pk)+ send_account_delete_confirmation_email.delay(user.token, user.email)messages.success(request, pgettext('Storefront message, when user requested his account removed',@@ -144,6 +145,6 @@ def account_delete(request, pk):def account_delete_confirm(request, token):user = get_object_or_404(User, token=token)- user.delete()+ # user.delete()return TemplateResponse(request, 'account/account_delete_confirm.html', {'user': user})diff --git a/templates/account/details.html b/templates/account/details.htmlindex 222b4b92d6..f859775180 100644--- a/templates/account/details.html+++ b/templates/account/details.html@@ -154,7 +154,7 @@<div class="tab-pane fade" id="settings" role="tabpanel"><div class="row "><div class="d-block mx-auto text-center">- <form action="" method="post">+ <form action="{% url 'account:delete' pk=request.user.pk %}" method="post">{% csrf_token %}<p>{% blocktrans context "Message informing about the process of account removal" %}diff --git a/templates/templated_email/account/account_delete.email b/templates/templated_email/account/account_delete.emailnew file mode 100644index 0000000000..aa640ac19c--- /dev/null+++ b/templates/templated_email/account/account_delete.email@@ -0,0 +1,29 @@+{% load i18n %}++{% block subject %}+ {% trans "Delete your account" context "Account delete reset e-mail subject" %}+{% endblock %}++{% block plain %}+{% blocktrans context "Account delete reset e-mail text" %}+Hi!++You're receiving this e-mail because you or someone else has requested a deletion of your user account at {{ domain }}.+Click the link below to delete your account.++Please note that this action is permanent and cannot be reversed.+{% endblocktrans %}++{{ url }}++This is an automatically generated email, please do not reply.++{% blocktrans context "Account delete reset e-mail text" %}+Sincerely,+{{ site_name }}+{% endblocktrans %}+{% endblock %}++{% block html %}+{% include 'templated_email/compiled/account_delete.html' %}+{% endblock %}diff --git a/templates/templated_email/source/account_delete.mjml b/templates/templated_email/source/account_delete.mjmlnew file mode 100644index 0000000000..9c0c22d06d--- /dev/null+++ b/templates/templated_email/source/account_delete.mjml@@ -0,0 +1,38 @@+<mjml>+ <mj-head>+ <mj-include path="./shared/styles" />+ </mj-head>+ <mj-body>+ <mj-container>+ <mj-section css-class="no-display">+ <mj-column>+ <mj-text>+ {% load i18n %}+ </mj-text>+ </mj-column>+ </mj-section>+ <mj-include path="./shared/header" />+ <mj-section>+ <mj-column>+ <mj-text font-size="16px">+ {% trans "Hi!" context "Account delete e-mail text" %}+ </mj-text>+ <mj-text>+ {% blocktrans trimmed context "Account delete e-mail text" %}+ You're receiving this e-mail because you or someone else has requested a deletion of your user account at {{ domain }}.<br/>+ Click the link below to delete your account.++ Please note that this action is permanent and cannot be reversed.+ {% endblocktrans %}+ </mj-text>+ <mj-text>+ <a href="{{ url }}">+ {{ url }}+ </a>+ </mj-text>+ </mj-column>+ </mj-section>+ <mj-include path="./shared/footer" />+ </mj-container>+ </mj-body>+</mjml>diff --git a/tests/test_account.py b/tests/test_account.pyindex 19a75c1836..3f5adf629d 100644--- a/tests/test_account.py+++ b/tests/test_account.py@@ -279,7 +279,8 @@ def test_view_account_delete(url = reverse('account:delete', args=[customer_user.pk])response = authorized_client.post(url)assert response.status_code == 302- send_confirmation_mock.assert_called_once_with(str(customer_user.pk))+ send_confirmation_mock.assert_called_once_with(+ customer_user.token, customer_user.email)def test_view_account_delete_confirm(customer_user, authorized_client):