- {% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}
+ {% page_url 'shop-password-reset' as password_reset_url %}
+
{% trans "The password reset link is invalid, possibly because it has already been used." %}
{% trans "Please provide a valid email address" %}
+
+
+
+
+
+
+
+{% endblock form_content %}
diff --git a/shop/templates/shop/email/register-user-activate-body.txt b/shop/templates/shop/email/register-user-activate-body.txt
new file mode 100644
index 000000000..aaa20c53a
--- /dev/null
+++ b/shop/templates/shop/email/register-user-activate-body.txt
@@ -0,0 +1,12 @@
+{% load i18n %}{% autoescape off %}
+{% blocktrans %}You're receiving this email because you registered a new account
+for '{{ user }}' at {{ site_name }}.{% endblocktrans %}
+
+{% trans "Please go to the following webpage to activate your new account:" %}
+{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
+
+{% trans "Thanks for visiting our site!" %}
+
+{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
+
+{% endautoescape %}
diff --git a/shop/templates/shop/email/register-user-activate-subject.txt b/shop/templates/shop/email/register-user-activate-subject.txt
new file mode 100644
index 000000000..d9cf2f6ad
--- /dev/null
+++ b/shop/templates/shop/email/register-user-activate-subject.txt
@@ -0,0 +1,3 @@
+{% load i18n %}{% autoescape off %}
+{% blocktrans %}Activate your new account on {{ site_name }}{% endblocktrans %}
+{% endautoescape %}
diff --git a/shop/templates/shop/email/reset-password-body.txt b/shop/templates/shop/email/reset-password-body.txt
index c3c6b9b16..98938beb7 100644
--- a/shop/templates/shop/email/reset-password-body.txt
+++ b/shop/templates/shop/email/reset-password-body.txt
@@ -1,11 +1,11 @@
{% load i18n %}{% autoescape off %}
-{% blocktrans %}You're receiving this email because you requested a password reset for your user
+{% blocktrans %}You're receiving this email because you requested to reset the password for your
account '{{ user }}' at {{ site_name }}.{% endblocktrans %}
-{% trans "Please go to the following page and choose a new password:" %}
+{% trans "Please go to the following webpage and choose a new password:" %}
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
-{% trans "Thanks for using our site!" %}
+{% trans "Thanks for visiting our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
diff --git a/shop/urls/auth.py b/shop/urls/auth.py
index d0b1177db..e931aa0b5 100644
--- a/shop/urls/auth.py
+++ b/shop/urls/auth.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
from django.conf.urls import url
from rest_auth.views import PasswordChangeView
-from shop.forms.auth import RegisterUserForm, ContinueAsGuestForm
+from shop.forms.auth import RegisterUserForm, RegisterUserActivateForm, ContinueAsGuestForm
from shop.views.auth import AuthFormsView, LoginView, LogoutView, PasswordResetView
urlpatterns = [
@@ -12,6 +12,8 @@
name='login'),
url(r'^register/?$', AuthFormsView.as_view(form_class=RegisterUserForm),
name='register-user'),
+ url(r'^register-activate/?$', AuthFormsView.as_view(form_class=RegisterUserActivateForm),
+ name='register-user-activate'),
url(r'^continue/?$', AuthFormsView.as_view(form_class=ContinueAsGuestForm),
name='continue-as-guest'),
diff --git a/shop/views/auth.py b/shop/views/auth.py
index 53113ff13..52011fe4f 100644
--- a/shop/views/auth.py
+++ b/shop/views/auth.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.contrib.auth import logout, get_user_model
+from django.contrib.auth import logout, get_user_model, authenticate, login
from django.contrib.auth.models import AnonymousUser
from django.contrib.auth.tokens import default_token_generator
from django.utils.encoding import force_text
@@ -146,4 +146,13 @@ def post(self, request, uidb64=None, token=None):
serializer.errors, status=status.HTTP_400_BAD_REQUEST
)
serializer.save()
- return Response({"success": _("Password has been reset with the new password.")})
+
+ # TODO: the following code can be simplified to ``customer = serializer.save().customer``
+ # whenever https://github.com/Tivix/django-rest-auth/pull/334 has been merged
+ customer = serializer.set_password_form.user.customer
+ customer.recognize_as_registered(request)
+ user = authenticate(username=customer.user.username, password=serializer.data['new_password1'])
+ login(request, user)
+
+ msg = _("The password for '{email}' has been reset by a new password.")
+ return Response({'success': msg.format(email=customer.email)})