Skip to content

Commit

Permalink
Update notification content
Browse files Browse the repository at this point in the history
  • Loading branch information
孙永强 committed Aug 14, 2024
1 parent b85dd6b commit 8153729
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
1 change: 1 addition & 0 deletions seahub/api2/endpoints/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions seahub/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
20 changes: 20 additions & 0 deletions seahub/templates/registration/browse_login_email.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'email_base.html' %}

{% load i18n %}

{% block email_con %}

{% autoescape off %}

<p style="color:#121214;font-size:14px;">{% trans "Hi," %}</p>

<p style="font-size:14px;color:#434144;">
{% blocktrans with account=email %}You are currently logging into this site using a browser{% endblocktrans %}
</p>
<p style="font-size:14px;color:#434144;margin-left: auto">
{{ email }}
</p>

{% endautoescape %}

{% endblock %}
5 changes: 2 additions & 3 deletions seahub/templates/registration/new_device_login_email.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
<p style="color:#121214;font-size:14px;">{% trans "Hi," %}</p>

<p style="font-size:14px;color:#434144;">
{% 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 %}
</p>


<p style="font-size:14px;color:#434144;">
{% 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." %}
</p>

{% endautoescape %}
Expand Down
7 changes: 2 additions & 5 deletions seahub/templates/registration/password_change_email.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@

{% block email_con %}

{% autoescape off %}

<p style="color:#121214;font-size:14px;">{% trans "Hi," %}</p>

<p style="font-size:14px;color:#434144;">
{% blocktrans with account=email %}You submitted a password change request on {{ time }}. {% endblocktrans %}
{% blocktrans with account=email %}Your password was changed. {% endblocktrans %}
</p>
<p style="font-size:14px;color:#434144;">
{% trans "You have successfully changed your password!" %}
{{ email }}
</p>

{% endautoescape %}

{% endblock %}

0 comments on commit 8153729

Please sign in to comment.