1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-05-11 09:24:38 +00:00

update email content

This commit is contained in:
孙永强 2024-08-16 15:39:09 +08:00
parent b94af23c30
commit b19e942841
7 changed files with 40 additions and 57 deletions
frontend/src/components/user-settings
seahub

View File

@ -130,8 +130,7 @@ class EmailNotice extends React.Component {
);
})}
<h4 className="mt-3 h6">{gettext('Notifications of login')}</h4>
<p className="mb-1">{gettext('Send a mail as soon as a new device or browser has signed into the account (like google and many other services do).')}</p>
<h4 className="mt-3 h6">{gettext(' Send a mail as soon as a new device or browser has signed into the account')}</h4>
{this.loginOption.map((item, index) => {
return (
<div className="d-flex" key={`login-updates-${index}`}>

View File

@ -214,12 +214,14 @@ def get_token_v2(request, username, platform, device_id, device_name,
raise serializers.ValidationError('invalid platform')
enable_new_device_email = bool(UserOptions.objects.get_login_email_enable_status(username))
if not TokenV2.objects.filter(user=username, device_id=device_id).first() and enable_new_device_email:
email_template_name='registration/new_device_login_email.html'
email_template_name='registration/login_email.html'
send_to = email2contact_email(username)
site_name = get_site_name()
c = {'email': send_to}
c = {
'name': email2nickname(username)
}
try:
send_html_email(_("New Device Login on %s") % site_name,
send_html_email(_("Welcome to %s") % site_name,
email_template_name, c, None,
[send_to])
except Exception as e:

View File

@ -13,6 +13,7 @@ from constance import config
from seaserv import ccnet_api
SESSION_KEY = '_auth_user_name'
SESSION_USERS_LOGIN = '_already_loging_users'
BACKEND_SESSION_KEY = '_auth_user_backend_2'
REDIRECT_FIELD_NAME = 'next'
SESSION_MOBILE_LOGIN_KEY = "MOBILE_LOGIN"
@ -119,12 +120,13 @@ def logout(request):
session data.
Also remove all passwords used to decrypt repos.
"""
already_logged_list = request.session.get('_already_logged', [])
already_logged_list = request.session.get(SESSION_USERS_LOGIN, [])
request.session.flush()
if request.user.username not in already_logged_list:
already_logged_list.append(request.user.username)
request.session['_already_logged'] = already_logged_list
if hasattr(request, 'user'):
username = request.user.username
if username not in already_logged_list:
already_logged_list.append(username)
request.session[SESSION_USERS_LOGIN] = already_logged_list
from seahub.base.accounts import User
if isinstance(request.user, User):
# Do not directly/indirectly import models in package root level.

View File

@ -20,7 +20,7 @@ from saml2.ident import decode
from seaserv import seafile_api, ccnet_api
from seahub.settings import SSO_SECRET_KEY
from seahub.auth import REDIRECT_FIELD_NAME, get_backends
from seahub.auth import login as auth_login
from seahub.auth import login as auth_login, SESSION_USERS_LOGIN
from seahub.auth.models import SocialAuthUser
from seahub.auth.decorators import login_required
from seahub.auth.forms import AuthenticationForm, CaptchaAuthenticationForm, \
@ -52,7 +52,7 @@ from seahub.onlyoffice.settings import ONLYOFFICE_DESKTOP_EDITOR_HTTP_USER_AGENT
from seahub.utils import send_html_email
from django.utils.translation import gettext_lazy as _
from seahub.base.templatetags.seahub_tags import email2contact_email
from seahub.base.templatetags.seahub_tags import email2contact_email, email2nickname
# Get an instance of a logger
logger = logging.getLogger(__name__)
@ -78,16 +78,16 @@ def log_user_in(request, user, redirect_to):
# Okay, security checks complete. Log the user in.
auth_login(request, user)
enable_login_email = bool(UserOptions.objects.get_login_email_enable_status(user.username))
already_logs = request.session.get('_already_logged', [])
if user.username not in already_logs and enable_login_email:
email_template_name = 'registration/browse_login_email.html'
already_login_users = request.session.get(SESSION_USERS_LOGIN, [])
if user.username not in already_login_users and enable_login_email:
email_template_name = 'registration/login_email.html'
send_to = email2contact_email(request.user.username)
site_name = get_site_name()
c = {
'email': send_to
'name': email2nickname(user.username)
}
try:
send_html_email(_("%s account login reminder") % site_name,
send_html_email(_("Welcome to %s") % site_name,
email_template_name, c, None,
[send_to])
except Exception as e:

View File

@ -1,20 +0,0 @@
{% 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 %}

View File

@ -0,0 +1,21 @@
{% extends 'email_base.html' %}
{% load i18n %}
{% block email_con %}
{% autoescape off %}
<p style="font-size:14px;color:#434144;">
{% blocktrans with account=name %}Dear, {{ account }}{% endblocktrans %}
</p>
<p style="font-size:14px;color:#434144;">
Greetings!
</p>
<p style="font-size:14px;color:#434144;">
{% trans " We are thrilled to inform you that you have successfully joined Seafile - a cloud-based platform dedicated to file management and team collaboration. Here, you'll find seamless and secure digital workspaces for document sharing, version control, and teamwork." %}
</p>
{% endautoescape %}
{% endblock %}

View File

@ -1,21 +0,0 @@
{% 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 trying to log in to your account with a new device {{ account }}{% endblocktrans %}
</p>
<p style="font-size:14px;color:#434144;">
{% trans "If you do not have this operation, please change your password as soon as possible." %}
</p>
{% endautoescape %}
{% endblock %}