diff --git a/seahub/api2/endpoints/user.py b/seahub/api2/endpoints/user.py index 89bd39f373d..3e783b49a04 100644 --- a/seahub/api2/endpoints/user.py +++ b/seahub/api2/endpoints/user.py @@ -250,6 +250,7 @@ def post(self, request): send_to = email2contact_email(request.user.username) site_name = get_site_name() c = { + 'email': send_to, 'time': datetime.now().strftime('%Y-%m-%d %H:%M:%S') } send_html_email(_("Successfully Changed Password on %s") % site_name, diff --git a/seahub/auth/views.py b/seahub/auth/views.py index b163bdd7332..29b85f26677 100644 --- a/seahub/auth/views.py +++ b/seahub/auth/views.py @@ -78,16 +78,16 @@ def log_user_in(request, user, redirect_to): # Okay, security checks complete. Log the user in. auth_login(request, user) - # if UserLoginLog.objects.filter(username=user.username).count() == 1: - # email_template_name = 'registration/password_change_email.html' - # send_to = email2contact_email(request.user.username) - # site_name = get_site_name() - # c = { - # 'time': datetime.now().strftime('%Y-%m-%d %H:%M:%S') - # } - # send_html_email(_("Successfully Changed Password on %s") % site_name, - # email_template_name, c, None, - # [send_to]) + if UserLoginLog.objects.filter(username=user.username, login_success=1).count() == 1: + email_template_name = 'registration/browse_login_email.html' + send_to = email2contact_email(request.user.username) + site_name = get_site_name() + c = { + 'email': send_to + } + send_html_email(_("%s account login reminder") % site_name, + email_template_name, c, None, + [send_to]) return HttpResponseRedirect(redirect_to) def _handle_login_form_valid(request, user, redirect_to, remember_me): diff --git a/seahub/templates/registration/browse_login_email.html b/seahub/templates/registration/browse_login_email.html new file mode 100644 index 00000000000..9b90f9f436c --- /dev/null +++ b/seahub/templates/registration/browse_login_email.html @@ -0,0 +1,20 @@ +{% extends 'email_base.html' %} + +{% load i18n %} + +{% block email_con %} + +{% autoescape off %} + +

{% trans "Hi," %}

+ +

+{% blocktrans with account=email %}You are currently logging into this site using a browser{% endblocktrans %} +

+

+{{ email }} +

+ +{% endautoescape %} + +{% endblock %} diff --git a/seahub/templates/registration/new_device_login_email.html b/seahub/templates/registration/new_device_login_email.html index fa1e9a9e4e8..343e5c1e473 100644 --- a/seahub/templates/registration/new_device_login_email.html +++ b/seahub/templates/registration/new_device_login_email.html @@ -9,12 +9,11 @@

{% trans "Hi," %}

-{% blocktrans with account=email %}You are attempting to log in to your account {{ account }} on {{ site_name }} using a new device{% endblocktrans %} +{% blocktrans with account=email %}You are trying to log in to your account with a new device {{ account }}{% endblocktrans %}

-

-{% trans "If you have not attempted to login with a new device, please change your password as soon as possible." %} +{% trans "If you do not have this operation, please change your password as soon as possible." %}

{% endautoescape %} diff --git a/seahub/templates/registration/password_change_email.html b/seahub/templates/registration/password_change_email.html index 6c035893a72..00f17daa075 100644 --- a/seahub/templates/registration/password_change_email.html +++ b/seahub/templates/registration/password_change_email.html @@ -4,17 +4,14 @@ {% block email_con %} -{% autoescape off %} -

{% trans "Hi," %}

-{% blocktrans with account=email %}You submitted a password change request on {{ time }}. {% endblocktrans %} +{% blocktrans with account=email %}Your password was changed. {% endblocktrans %}

-{% trans "You have successfully changed your password!" %} +{{ email }}

-{% endautoescape %} {% endblock %}